I have a simple web map with one polygon layer in it. I wanted to add a field to the popup window to show area in hectares for this layer. I use the following Arcade expression:
var hecs = Area($feature, 'hectares') return round(hecs, 2)
The expression runs successfully. When I go to look at the value for each feature in the layer from the popup window, the areas are way off. I attached an image. Within the image, you will see 3 fields:
I did a further check to see if our system values were calculating correctly by making a copy of the data in ArcMap, adding a field for Hectares and Calculated geometry for hectares. Our system values are correct.
I would have thought that this could be a projection issue, but the values are so grossly off, I don't think that's the issue. But, for the record, the layer is a hosted feature layer that was added to ArcGIS online in the native projection that AGOL uses:
Finally, I tested on some other layers and am getting the same issue. I tried different area values (i.e. square metres, square kilometres) and they are all way off.
Can anyone suggest what is wrong with these areas?
Your table values are correct.
Web mercator is not a projection to be used for anything geometry related
I think you were on the right track about the projection. Our experience with Arcade's area function has been that regardless of the projection of the data itself, the output will depend on the web map's projection. Generally, this is the Web Mercator, and can yield very different area measurements depending on your latitude.
What you may want to look into is the AreaGeodetic function. Function reference here.
I've attached a couple of images. One shows by color the Area to AreaGeodetic ratio, the other gives the actual values as labels.
Hi @MikeMacRae ,
"Note that geometries fetched from feature services, especially polylines and polygons, are generalized according to the view's scale resolution. Be aware that using a feature's geometry (i.e. $feature) as input to any geometry function will yield results only as precise as the view scale. Therefore, results returned from geometry operations in the visualization and labeling profiles may be different at each scale level. Use these functions at your discretion within these contexts."