Geometry

sealed class Geometry : JsonSerializable

Base class for all classes that represent geometric shapes. Geometry is the base class for two-dimensional (x,y) and three-dimensional (x,y,z) geometries, such as Point, Multipoint, Polyline, Polygon, and Envelope. It represents real-world objects by defining a shape at a specific geographic location, and is used throughout the API to represent the shapes of features and graphics, layer extents, viewpoints, and GPS locations. It is also used to define the inputs and outputs for spatial analysis and geoprocessing operations, and to measure distances and areas.

All types of geometry have the following characteristics:

  • A SpatialReference indicating the coordinate system used by its coordinates.

  • Can be empty, indicating that they have no specific location or shape.

  • May have z-values and/or m-values to define elevation and measures, respectively.

  • Can be converted to and from JSON to be persisted or to be exchanged directly with REST services.

Immutability

Most geometries are created and not changed for their lifetime. Examples include features created to be stored in a geodatabase or read from a non-editable layer, and features returned from tasks such as a spatial query, geocode operation, network trace, or geoprocessing task. Immutable geometries (geometries that cannot be changed) offer important benefits to your app. They are inherently thread-safe, help prevent inadvertent changes, and allow for certain performance optimizations.

If you want to modify the shape of a Geometry there are two options available:

Note that the GeometryEngine offers a range of topological and spatial transformations that can create a new geometry from an existing geometry. The GeometryEngine allows you to perform actions on an existing geometry, such as a buffer, cut, clip, densify, or project, to produce a new output geometry. See GeometryEngine to explore various supported geometric operations.

Coordinate units

The coordinates that define a geometry are only meaningful in the context of the geometry's SpatialReference. The vertices and spatial reference together allow your app to translate a real-world object from its location on the Earth to its location on your map or scene.

In some cases, a geometry's spatial reference may not be set. For example, a com.arcgismaps.mapping.view.Graphic that does not have a spatial reference is drawn using the same spatial reference as the com.arcgismaps.mapping.view.GeoView to which it was added. If the coordinates are in a different spatial reference, the graphics may not display in the correct location, or at all.

When using GeometryBuilder to create a Polyline or Polygon from a collection of Point, you don't need to set the spatial reference of every point before you add it to the builder, as it is assigned the spatial reference of the builder itself. In most other cases, such as when using a geometry in geometry operations or when editing a feature table, Geometry.spatialReference must be set.

Spatial reference and projection

Changing the coordinates of a geometry to have the same shape and location represented using a different SpatialReference is known as "projection" or sometimes as "reprojection". Because geometries are immutable, they do not have any member methods that project, transform, or otherwise modify their content.

Since

200.1.0

See also

Inheritors

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Indicates the dimensionality of a Geometry, relating to the number of spatial dimensions in which the geometry may have a size. You can use Geometry.dimension to work out what kind of symbol can be applied to a specific type of geometry. For example, Point and Multipoint are both zero-dimensional point geometries, and both can be displayed using a type of com.arcgismaps.mapping.symbology.MarkerSymbol. Polygon and Envelope are both 2-dimensional area geometries that can be displayed using a type of com.arcgismaps.mapping.symbology.FillSymbol.

Link copied to clipboard

The minimum enclosing bounding-box (or Envelope) that covers the geometry.

Link copied to clipboard

True if this geometry contains curve segments, false otherwise. ArcGIS software supports polygon and polyline geometries that contain curve segments (where Segment.isCurve is true, sometimes known as true curves or nonlinear segments). Curves may be present in certain types of data, such as Mobile Map Packages (MMPK) or geometry JSON. When connecting to ArcGIS feature services that support curves (see com.arcgismaps.arcgisservices.ArcGISFeatureServiceInfo.supportsTrueCurve), this API retrieves densified versions of curve feature geometries by default.

Link copied to clipboard

True if the geometry has m values (measure values), false otherwise. M is a vertex value that is stored with the geometry. These values typically represent non-spatial measurements or attributes.

Link copied to clipboard

True if the geometry has z-coordinate values, false otherwise. Only 3D geometries contain z-coordinate values. These values typically represent elevation, height, or depth.

Link copied to clipboard

True if the geometry is empty, false otherwise. A geometry is empty if it does not have valid geographic coordinates, even if the SpatialReference is specified. An empty Geometry is a valid object that has no location in space.

Link copied to clipboard

The spatial reference for this geometry. This can be null if the geometry is not associated with a SpatialReference.

Functions

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean

fun equals(right: Geometry, tolerance: Double): Boolean

Checks if two geometries are approximately the same within the given tolerance. This function performs a lightweight comparison of two geometries that might be useful when writing test code. It uses the tolerance to compare each of x, y, and any other values the geometries possess (such as z or m) independently in the manner: abs(value1 - value2) <= tolerance. The single tolerance value is used even if the x, y, z or m units differ. This function does not respect modular arithmetic of spatial references which wrap around, so longitudes of -180 and +180 degrees are considered to differ by 360 degrees.

Link copied to clipboard
open override fun hashCode(): Int

Inherited functions

Link copied to clipboard
open override fun toJson(): String

Convert an object to JSON string.