I am migrating an ArcObject module into Pro SDK that calculates the area of polygons that would be copied from one feature class to another.
In the legacy code polygons reprojected into Albers US 1983 coordinate (102003) system from NAD 1983 GCS.
There are discrepancies when calculating area of a polygon between Calculate Geometry on the attribute table and the code I tried in Pro SDK. I need to produce the same result what Calculate Geometry on the attribute table or Measurement tool.
Here is my code:
public static double CalculateArea(List<Geometry> geos)
{
List<Polygon> polygons = [];
var spRefAlbers = SpatialReferenceBuilder.CreateSpatialReference(AlbersUS1983WkId);
foreach (var geo in geos)
{
if (GeometryEngine.Instance.Project(geo, spRefAlbers) is Polygon plg)
{
polygons.Add(plg);
}
}
PolygonBuilderEx pLbuilderEx = new(polygons, AttributeFlags.None)
{
HasZ = false,
SpatialReference = spRefAlbers
};
//Unit for AlbersUS1983 is meter
return Math.Round((pLbuilderEx.ToGeometry().Area * 0.000247105381), 3);
}
I also tried pLbuilderEx.ToGeometry().Extent.Area, getting polygon exterior ring, geodesic area calculation etc. but no luck
There is about 500 acres difference any idea why?
I'd appreciate any help. Thanks!
Not sure if this is specifically your issue. About a year and a half ago I logged BUG-000154940 related to: Inaccurate results when calculating the geometry(Area) for shapefiles when using Pro. This was the case both from the GUI and from the SDK.
This looks to be the current status:
Submitted January 6, 2023
Last Modified February 22, 2023
Applies to ArcGIS Pro
Version found 3.0.3
Operating System Windows OS
Operating System Version10.0
Status In Review
@RobChasanI figured the problem. I was getting the geometry from wrong layer. I resolved the issue. Thanks for replying anyway.