ShapePreservingArea(Geometry,AreaUnit) Method
Calculates the area of the geometry on the surface of the Earth ellipsoid. This method
preserves the shape of the geometry in its coordinate system.
Parameters
- geometry
- The input geometry. Cannot be null and its spatial reference cannot be null.
- areaUnit
- The unit of the output area. If null, the area is square meters.
Return Value
The calculated shape preserving area of the geometry in . If is null, then the shape preserving area is in square meters.
If the geometry is empty, then zero is returned.
Calculate area of geometry on surface of Earth's ellipsoid - ShapePreservingArea
// pt
MapPoint pt = MapPointBuilderEx.CreateMapPoint(1.0, 3.0, SpatialReferences.WebMercator);
double area = GeometryEngine.Instance.ShapePreservingArea(pt); // area = 0
List<MapPoint> pts = new List<MapPoint>();
pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 1.0, 3.0));
pts.Add(MapPointBuilderEx.CreateMapPoint(1.0, 3.0, 3.0));
pts.Add(MapPointBuilderEx.CreateMapPoint(3, 3, 3.0));
pts.Add(MapPointBuilderEx.CreateMapPoint(3.0, 1.0, 3.0));
// multipoint
Multipoint mPt = MultipointBuilderEx.CreateMultipoint(pts);
area = GeometryEngine.Instance.ShapePreservingArea(mPt); // area = 0
// polyline
Polyline polyline = PolylineBuilderEx.CreatePolyline(pts);
area = GeometryEngine.Instance.ShapePreservingArea(polyline); // area = 0
// polygon
Polygon polygon = PolygonBuilderEx.CreatePolygon(pts, SpatialReferences.WGS84);
area = GeometryEngine.Instance.ShapePreservingArea(polygon);
polygon = PolygonBuilderEx.CreatePolygon(pts, SpatialReferences.WebMercator);
area = GeometryEngine.Instance.ShapePreservingArea(polygon);
polygon = PolygonBuilderEx.CreatePolygon(new[]
{
MapPointBuilderEx.CreateMapPoint( -170, 45),
MapPointBuilderEx.CreateMapPoint( 170, 45),
MapPointBuilderEx.CreateMapPoint( 170, -45),
MapPointBuilderEx.CreateMapPoint( -170, -54)
}, SpatialReferences.WGS84);
var area_meters = GeometryEngine.Instance.ShapePreservingArea(polygon);// , AreaUnits.SquareMeters);
var area_miles = GeometryEngine.Instance.ShapePreservingArea(polygon, AreaUnit.SquareMiles);
// area_meters - 352556425383104.37
// area_miles - 136122796.848425
Target Platforms: Windows 11, Windows 10
ArcGIS Pro version: 3 or higher.