Polygon

A multipart shape used to represent an area. Polygon geometries represent the shape and location of areas, for example, a country, island, or a lake. A polygon can be used as the geometry of features and graphics, or as input or output of tasks or geoprocessing operations, such as the output of a drive-time analysis or a GeometryEngine.bufferOrNull operation.

Each part of a multipart polygon is a series of connected Segment objects forming a closed ring. Each part must not cross any other part, but may lie completely inside or outside another part. For example, a polygon representing the state of Hawaii would comprise eight disjoint parts, one representing each island. A polygon representing the country of South Africa, which completely surrounds the enclave of Lesotho, would comprise two parts, one contained inside the other.

Polygon is similar to Polyline in that they are both composed of a series of connected segments. Like Polyline, the polygon class is a Multipart, which provides members for iterating the segments and points of each part in a polygon. Unlike parts in a Polyline, however, each part of a polygon defines a closed area, so the end point of the last segment in the part is always in the same location as the start point of the first segment, forming a closed boundary.

When defining a polygon part, there is no need to explicitly close it by repeating the start point as the last point. Polygon parts are always interpreted as enclosed areas by this API. However, you may need to simplify a polygon created with this API before storing it in a geodatabase or using it in geometry operations that rely on topological consistency.

Interior rings to make donut polygons should be counter-clockwise in direction to have the correct topology.

If there is ever a doubt about the topological correctness of a polygon, call the GeometryEngine.simplifyOrNull method to correct any issues. This is especially true if you pass a polygon to ArcGIS Server for a geoprocessing task to avoid any ArcGIS Server errors being thrown or to rectify polygons that may be self-intersecting, have rings which are partially contained in each other, or contain incorrect ring orientations.

Polygons are based upon the parent Geometry class. The geometry object is immutable which means that you can not change its shape once it is created. If you need to create a new polygon or modify it once it has been created, use the PolygonBuilder class.

A polygon can be used as the geometry of a com.arcgismaps.data.Feature or com.arcgismaps.mapping.view.Graphic. To obtain the geometry on these objects, use com.arcgismaps.mapping.GeoElement.geometry.

Since

200.1.0

See also

Constructors

Link copied to clipboard
constructor(mutableParts: Iterable<MutablePart>)

Constructs a Polygon with the given collection of MutableParts.

constructor(points: Iterable<Point>, spatialReference: SpatialReference? = null)

Constructs a Polygon with the given collection of Points.

Inherited 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 parts for the multipart. This is a copy and the any changes must be set.

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

Creates a polyline containing paths for all the rings in this polygon.

Inherited 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
Link copied to clipboard
open override fun toJson(): String

Convert an object to JSON string.