Labeling polygons with area

1010
3
10-26-2017 07:04 PM
PaulHaakma
Regular Contributor

Can anyone clarify what the proper way is to create a label expression in ArcGIS Pro that displays the area of a polygon, no matter the source of the data?

This link:

Specify text for labels—ArcGIS Pro | ArcGIS Desktop 

suggests using (for Python):  round(float([AREA]), 1)

or for Arcade:  round(number($feature.AREA), 1)

But when I try to validate either of those I get the error 'Invalid field AREA'. This happens for polygon datasets I tried both that were hosted in AGOL and from a Portal using Postgres.

Datasets hosted in AGOL seem to have a 'Shape__Area' field that I can label from, but the dataset from the Portal doesn't have that attribute.

So how can/should I be labeling the dataset from Portal? Is there something *wrong* with the Portal dataset, or feature service, or is there another way to access the geometry of the feature?

0 Kudos
3 Replies
CiaraRowland-Simms
Esri Contributor

Hi Paul, 

Different data types may have different names for their shape area field. This seems to be a common issue folks run into (stack-overflow example here). Arcade can help you here by giving you access to the feature geometry, which you can then calculate the area on:

area(geometry($feature))

Hope that helps!

Ciara

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi Paul Haakma  and Ciara Rowland-Simms , 

As far as I understand it is not necessary to convert the $feature to a Geometry. You can use the Area directly on the $feature. According to the documentation, the AreaGeodetic function is more accurate, but only works when your source is using Web Mercator (wkid 3857) or a WGS 84 (wkid 4326) spatial reference. 

I also recommend specifying the units in which you want to specify the area. See a list of valid values here: Geometry Functions | ArcGIS for Developers . Something like this:

AreaGeodetic($feature, 'square-meters')
JCooley_ClackamasSWCD
New Contributor II

You need to use the AreaGeodetic function if you are working with a hosted feature layer.  The Shape__Area field is always populated with the planar area and not the geodesic area.  Web Mercator does not preserve area!  The difference between geodesic and planar area is really significant as you move away from the equator.

 

0 Kudos