laptop and a wrench

Bug

When running the lengths() function from the ArcGIS API for Python on a Polyline object, the function fails and returns the error message, “The operation was attempted on an empty geometry".

ArcGIS API for Python
Bug-ID-Nummer BUG-000178221
EingereichtJuly 25, 2025
Zuletzt geändertSeptember 4, 2025
Gilt fürArcGIS API for Python
Gefunden in Version2.4.1
BetriebssystemN/A
BetriebssystemversionN/A
Behoben in Version2.4.2
StatusFixed

Workaround

Use the LengthUnits class to do this:

from arcgis.geometry import Polyline

from arcgis.geometry import lengths, LengthUnits

simple_polyline = Polyline({

  "paths": [[[-95.5, 30.2], [-95.6, 30.3]]],

  "spatialReference": {"wkid": 4326}

})

print(type(simple_polyline))

print(simple_polyline)

usFeet_simple = lengths(

  spatial_ref={"wkid": 4326},

  polylines=[simple_polyline],

  length_unit=LengthUnits.FOOT,

  calculation_type='geodesic',

  gis=gis

)

print("Length in US feet (simple):", usFeet_simple)

Schritte zur Reproduzierung

Bug-ID: BUG-000178221

Software:

  • ArcGIS API for Python

Benachrichtigung erhalten, wenn sich der Status eines Bugs ändert

Esri Support App herunterladen

Weitere Informationen zu diesem Thema erkunden

Unterstützung durch ArcGIS-Experten anfordern

An den technischen Support wenden

Esri Support App herunterladen

Zu Download-Optionen wechseln