Select to view content in your preferred language

arcgis.geometry.areas_and_lengths() bugged on ArcGIS Online Notebooks?

05-21-2021 06:03 PM
New Contributor III

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

Tags (2)
0 Kudos
3 Replies
MVP Esteemed Contributor

Perhaps raise an "issue" on their github site... they don't visit much here.

ArcGIS API for Python (

... sort of retired...
New Contributor III

Thx @DanPatterson! Posted a bug report on github.

BTW: do you have any suggestions on a better way to bulk calculate feature acres in Esri Python API? Perhaps even with ArcPy? 

0 Kudos
MVP Esteemed Contributor

you can access all the tools in arctoolbox if you have arcpy

... sort of retired...