I'm trying to bulk calculate acres for polygons in a hosted feature service using ArcGIS Online Notebook Standard (no ArcPy)
Is there a bug in the ArcGIS Online Notebook (API v1.8.4 at posting time) implementation of the arcgis.geometry.areas_and_lengths() function or is the API description missing vital information?
Through a lot of trial and error I figured out a set of parameters that ArcGIS Online Notebook would accept
- For length_unit it will only accept an ID number - e.g. 9002 - not esriSRUnit_Foot
- For area_unit it will only accept a dictionary - e.g. {"areaUnit" : "esriAcres"} - not an ID number or esriAcres
I could only get it to work with parameters formatted the following way:
from arcgis.geometry import lengths, areas_and_lengths, project
from arcgis.geometry import Point, Polyline, Polygon, Geometry
# create a JSON polygon geometry
geom_json = {"rings" : [[[0, 0], [0, 10], [10, 10],[10, 0],[0, 0]]],
"spatialReference" : {"wkid" : 4326}}
# create Geometry object
test_geom = Geometry(geom_json)
# calculate areas_and_lengths
areas_and_lengths(test_geom, 9035, {"areaUnit" : "esriAcres"}, "geodesic", 4326, None, False)
I welcome any suggestions on a more efficient way to calculate acres than one by one converting a Feature into a Geometry to then run areas_and_lengths().
Without using ArcPy though 🙂
edit: fixed typos