laptop and a wrench

Bogue

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
Numéro d’ID de bogue BUG-000178221
EnvoiJuly 25, 2025
Dernière modificationSeptember 4, 2025
S’applique àArcGIS API for Python
Version trouvée2.4.1
Système d’exploitationN/A
Version du système d’exploitationN/A
Version de correction2.4.2
StatutFixed

Solution de contournement

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)

Étapes pour reproduire

ID de bogue: BUG-000178221

Logiciel:

  • ArcGIS API for Python

Recevoir une notification lorsque le statut d’un bogue change

Télécharger l’application Esri Support

En savoir plus sur ce sujet

Obtenir de l’aide auprès des experts ArcGIS

Contacter le support technique

Télécharger l’application Esri Support

Accéder aux options de téléchargement