Show / Hide Table of Contents

Class Geometry

Base class for all classes that represent geometric shapes.

Inheritance
Object
Geometry
Envelope
MapPoint
Multipart
Multipoint
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Esri.ArcGISRuntime.Geometry
Assembly: Esri.ArcGISRuntime.dll
Syntax
public abstract class Geometry
Remarks

Geometry is the base class for two-dimensional (x,y) or three-dimensional (x, y, z) geometries. Objects that inherit from the Geometry class may also include a measure (m-value) for each vertex. The Geometry class provides functionality common to all types of geometry. MapPoint, Multipoint, Polyline, Polygon, and Envelope all inherit from Geometry and represent different types of shapes.

Geometry represents real-world objects by defining a shape at a specific geographic location. It is used throughout the API to represent the shapes of features and graphics, layer extents, viewpoints, and GPS locations. It is also used, for example, to define inputs and outputs for spatial analysis and geoprocessing operations and to measure distances and areas.

All types of geometry:

  • Have 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 some important benefits to your app. They are inherently thread-safe, help prevent inadvertent changes, and allow for certain performance optimizations.

On the surface, immutability may appear to present a problem when attempting to edit existing geometries. Creating and updating, however, is handled by the various types of GeometryBuilder<T>, which are designed to represent the state of a geometry under construction while allowing modifications, thus enabling editing workflows.

Additionally, GeometryEngine offers a range of topological and relational operations and spatial transformations that read the content of existing geometries and create new geometries, for example, project, move, scale, rotate, buffer, union, and so on. Relational tests such as intersects and overlaps are also available on GeometryEngine.

GeometryEngine, provides a wide range of methods that read the content of geometries and modify that content to create new geometries. There are methods to Project(Geometry, SpatialReference), MoveGeodetic(IEnumerable<MapPoint>, Double, LinearUnit, Double, AngularUnit, GeodeticCurveType), Cut(Geometry, Polyline), Densify(Geometry, Double), and Generalize(Geometry, Double, Boolean) geometries.

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. A Graphic that does not have a spatial reference is drawn using the same spatial reference as the geo view to which it was added. When using GeometryBuilder<T> to create a Polyline or Polygon from a collection of MapPoint, 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, 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.

Properties

Name Description
Dimension

Gets the number of dimensions for the geometry.

Extent

Gets the minimum enclosing Envelope of this geometry.

GeometryType

Gets the geometry type.

HasCurves

Gets a value indicating whether the geometry has any curves.

HasM

Gets a value indicating whether the geometry has M.

HasZ

Gets a value indicating whether the geometry has Z.

IsEmpty

Gets a value indicating whether or not the geometry is empty.

SpatialReference

Gets the spatial reference of this geometry.

Methods

Name Description
Equals(Geometry, Double)

Checks if two geometries are approximately same, within some tolerance.

FromJson(String)

Creates a Geometry from an ArcGIS JSON representation.

FromJson(String, SpatialReference)

Creates a geometry from an ArcGIS JSON representation.

IsEqual(Geometry)

Compares two geometries for exact equality. The types of geometry, order of points, all values, and the SpatialReference must all be the equal.

IsNullOrEmpty(Geometry)

Indicates whether the specified Geometry is null or empty.

ToJson()

Converts this geometry into an ArcGIS JSON representation.

Extension Methods

GeometryEngine.NormalizeCentralMeridian(Geometry)
GeometryEngine.NearestVertex(Geometry, MapPoint)
GeometryEngine.NearestCoordinate(Geometry, MapPoint)
GeometryEngine.NearestCoordinateGeodetic(Geometry, MapPoint, Double, LinearUnit)
GeometryEngine.Project(Geometry, SpatialReference)
GeometryEngine.Project(Geometry, SpatialReference, DatumTransformation)
GeometryEngine.Union(Geometry, Geometry)
GeometryEngine.Intersection(Geometry, Geometry)
GeometryEngine.Intersections(Geometry, Geometry)
GeometryEngine.Clip(Geometry, Envelope)
GeometryEngine.Simplify(Geometry)
GeometryEngine.Area(Geometry)
GeometryEngine.AreaGeodetic(Geometry, AreaUnit, GeodeticCurveType)
GeometryEngine.Cut(Geometry, Polyline)
GeometryEngine.Length(Geometry)
GeometryEngine.LengthGeodetic(Geometry, LinearUnit, GeodeticCurveType)
GeometryEngine.Buffer(Geometry, Double)
GeometryEngine.Distance(Geometry, Geometry)
GeometryEngine.Intersects(Geometry, Geometry)
GeometryEngine.Contains(Geometry, Geometry)
GeometryEngine.Overlaps(Geometry, Geometry)
GeometryEngine.Within(Geometry, Geometry)
GeometryEngine.Crosses(Geometry, Geometry)
GeometryEngine.Disjoint(Geometry, Geometry)
GeometryEngine.Touches(Geometry, Geometry)
GeometryEngine.Densify(Geometry, Double)
GeometryEngine.Offset(Geometry, Double, OffsetType, Double, Double)
GeometryEngine.Generalize(Geometry, Double, Boolean)
GeometryEngine.Difference(Geometry, Geometry)
GeometryEngine.SymmetricDifference(Geometry, Geometry)
GeometryEngine.DensifyGeodetic(Geometry, Double, LinearUnit, GeodeticCurveType)
GeometryEngine.ConvexHull(Geometry)
GeometryEngine.Relate(Geometry, Geometry, String)
GeometryEngine.BufferGeodetic(Geometry, Double, LinearUnit, Double, GeodeticCurveType)
GeometryEngine.Boundary(Geometry)
GeometryEngine.IsSimple(Geometry)
GeometryEngine.CombineExtents(Geometry, Geometry)
GeometryEngine.RemoveM(Geometry)
GeometryEngine.RemoveZ(Geometry)
GeometryEngine.RemoveZAndM(Geometry)
GeometryExtensions.WithZ<T>(T, Double)
GeometryExtensions.WithM<T>(T, Double)
GeometryExtensions.WithZAndM<T>(T, Double, Double)

See Also

GeometryEngine
GeometryBuilder<T>

Applies to

TargetVersions
.NET Standard 2.0100.3 - 200.0
.NET 6.0100.13 - 200.0
.NET 6.0 Windows100.13 - 200.0
.NET 6.0 Android200
.NET 6.0 iOS200
.NET Framework100.0 - 200.0
.NET 5100.10 - 100.12
.NET Core 3.1100.7 - 100.12
Android100.0 - 100.15
iOS100.0 - 100.15
UWP100.0 - 200.0

Relevant samples

Add ENC exchange set: Display nautical charts per the ENC specification.
Add features: Add features to a feature layer.
Add graphics with symbols: Use a symbol style to display a graphic on a graphics overlay.
Analyze hotspots: Use a geoprocessing service and a set of features to identify statistically significant hot spots and cold spots.
In This Article
Back to top Copyright © 2022 Esri.