- All Implemented Interfaces:
JsonSerializable
Polygon geometries represent the shape and location of areas, for example, a country, island, or a lake. They 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.buffer(Iterable, Iterable, boolean)
operation.
Each part of a multipart polygon is a series of connected segments 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 created 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 GeometryEngine.simplify(Geometry)
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. You can also call GeometryEngine#simplify(Geometry)
to rectify
polygons that may be self-intersecting, have rings which are partially contained in each other, or contain incorrect
ring orientations.
Polygon
is immutable. To build a new polygon one point at a time, or modify an existing polygon, use a
PolygonBuilder
.
A Polygon
can be used as the geometry of a Feature
or Graphic
. To obtain the geometry, use
Feature.getGeometry()
or Graphic.getGeometry()
.
- Since:
- 100.0.0
- See Also:
-
Constructor Summary
ConstructorDescriptionCreates a new immutable Polygon containing a copy of the given Part.Polygon
(PartCollection parts) Creates a new immutable Polygon containing a copy of the given PartCollection.Polygon
(PartCollection parts, SpatialReference spatialReference) Creates a new Polygon containing a copy of the given PartCollection, and with the given SpatialReference.Polygon
(Part part, SpatialReference spatialReference) Creates a new Polygon containing a copy of the given Part, and with the given SpatialReference.Polygon
(PointCollection points) Creates a new immutable Polygon containing a copy of the Points in the given PointCollection.Polygon
(PointCollection points, SpatialReference spatialReference) Creates a new Polygon containing a copy of the Points in the given PointCollection, and with the given SpatialReference. -
Method Summary
Modifier and TypeMethodDescriptionCreates a polyline containing paths for all the rings in this polygon.Methods inherited from class com.esri.arcgisruntime.geometry.Geometry
equals, equals, fromJson, fromJson, getDimension, getExtent, getGeometryType, getSpatialReference, getUnknownJson, getUnsupportedJson, hasCurves, hashCode, hasM, hasZ, isEmpty, toJson
-
Constructor Details
-
Polygon
Creates a new immutable Polygon containing a copy of the Points in the given PointCollection. The SpatialReference of the new Polygon will match that of the given PointCollection.- Parameters:
points
- the PointCollection used to initialize the new Polygon- Since:
- 100.0.0
-
Polygon
Creates a new Polygon containing a copy of the Points in the given PointCollection, and with the given SpatialReference.This overload can be used to create a new Polygon with a specific SpatialReference from an existing PointCollection that has a null SpatialReference (the points are assigned the given SpatialReference-they are not projected).
- Parameters:
points
- the PointCollection containing points copied to the new PolygonspatialReference
- the SpatialReference of the new Polygon- Throws:
ArcGISRuntimeException
- if the SpatialReference ofpoints
does not match thespatialReference
- Since:
- 100.0.0
-
Polygon
Creates a new immutable Polygon containing a copy of the given Part. The SpatialReference of the new Polygon will match that of the given Part.- Parameters:
part
- the Part used to initialize the new Polygon- Since:
- 100.0.0
-
Polygon
Creates a new Polygon containing a copy of the given Part, and with the given SpatialReference.- Parameters:
part
- the Part to copy to the new PolygonspatialReference
- the SpatialReference of the new Polygon- Throws:
ArcGISRuntimeException
- if the SpatialReference ofpart
does not match thespatialReference
- Since:
- 100.0.0
-
Polygon
Creates a new immutable Polygon containing a copy of the given PartCollection. The SpatialReference of the new Polygon will match that of the given PartCollection.- Parameters:
parts
- the PartCollection used to initialize the new Polygon- Since:
- 100.0.0
-
Polygon
Creates a new Polygon containing a copy of the given PartCollection, and with the given SpatialReference.- Parameters:
parts
- the PartCollection to be copied to the new PolygonspatialReference
- the SpatialReference of the new Polygon- Throws:
ArcGISRuntimeException
- if the SpatialReference ofpart
does not matchspatialReference
- Since:
- 100.0.0
-
-
Method Details
-
toPolyline
Creates a polyline containing paths for all the rings in this polygon.- Returns:
- a new Polyline
- Since:
- 100.0.0
-