Select to view content in your preferred language

Calculate polygon area and perimeter in geodesic

1753
3
Jump to solution
03-04-2021 10:10 PM
PrashantKirpan
Frequent Contributor

Hi,

After adding polygon I want to calculate area and perimeter in geodesic unit. I'm able to calculate area and convert it into hectares but not sure how to calculate perimeter in kilometer.

Area I'm using below code.

var ft = (Feature)row; 
if (ft.GetShape().GeometryType == GeometryType.Polygon)
{
   var area = GeometryEngine.Instance.GeodesicArea(ft.GetShape()) / 10000; 
  //Calculate and convert area from meter to hectares
}

I couldn't find function to calculate perimeter in GeometryEngine. 

Any help would be appreciated.

-Prashant

0 Kudos
1 Solution

Accepted Solutions
KirkKuykendall1
Frequent Contributor

Did you try creating a polyline from segments (see example here) and passing that to GeometryEngine.GeodesicLength ?

View solution in original post

3 Replies
by Anonymous User
Not applicable

Hi @PrashantKirpan ,

Currently there is no option to add unit in the GeometryEngine, mostly are meters by default.

How I solved for that situation at the moment is - divided by 10 ^ 6 or (1000 * 1000) to get square meters.

Similarly for Nautical Miles divided by 1852 ^ 2 or (1862 * 1852) for area value.

 

Best Regards,

Than

 

KirkKuykendall1
Frequent Contributor

Did you try creating a polyline from segments (see example here) and passing that to GeometryEngine.GeodesicLength ?

PrashantKirpan
Frequent Contributor

Hi,

Thanks for the help. Working fine. Here is my sample code.

ICollection<Segment> collection = new List<Segment>();
poly.GetAllSegments(ref collection);
double lenght = 0;
foreach (var item in collection)
{
var polyline = new PolylineBuilder(item);
lenght += GeometryEngine.Instance.GeodesicLength(polyline.ToGeometry()) / 1000;
}

 

0 Kudos