HOW TO
Unlike a point feature, the coordinates of a polygon feature, which has an area, are indefinite. Therefore, to determine the coordinates of a polygon feature, the centroids of the polygons are calculated. Centroids are point features that represent the center of the polygon features.
This article describes the workflow to calculate the coordinate of polygon features based on its centroids using an Arcade expression in ArcGIS Online.
//return the geometry of the feature var poly = Geometry($feature); var result = ""; //return the centroid of the polygon feature if (!IsEmpty(poly)) { var pnt_centr = Centroid(poly); Console(pnt_centr); result = "(" + Round(pnt_centr.X, 2) + ", " + Round(pnt_centr.Y, 2) + ")"; } //return the result return result
The Coordinate field is populated with coordinates of the polygon features' centroids. The unit of the coordinates follows the map's coordinate system.
Alternatively, to calculate the coordinates in decimal degrees, use the following Arcade expressions in the Expression box:
function MetersToLatLon(mx, my) { var originShift = 2.0 * PI * 6378137.0 / 2.0; var lon = (mx / originShift) * 180.0; var lat = (my / originShift) * 180.0; lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0); return [lat, lon]; } var poly = Geometry($feature); var result = ""; if (!IsEmpty(poly)) { var pnt_centr = Centroid(poly); var latlon = MetersToLatLon(pnt_centr.x, pnt_centr.y); result = "(" + Round(latlon[0], 6) + ", " + Round(latlon[1], 6) + ")"; } else { result = ""; } return result
The Lat_Long field is populated with coordinates of the polygon features' centroids in decimal degrees.
Get help from ArcGIS experts
Download the Esri Support App