laptop and a wrench

Error

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
Número de ID del error BUG-000178221
EnviadoJuly 25, 2025
Última modificaciónSeptember 4, 2025
Relacionado conArcGIS API for Python
Versión encontrada2.4.1
Sistema operativoN/A
Versión de sistema operativoN/A
Versión corregida2.4.2
EstadoFixed

Solución alternativa

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)

Pasos para reproducir

ID del error: BUG-000178221

Software:

  • ArcGIS API for Python

Recibir notificaciones cuando cambie el estado de un error

Descargar la aplicación de soporte de Esri

Descubrir más sobre este tema

Obtener ayuda de expertos en ArcGIS

Contactar con el soporte técnico

Descargar la aplicación de soporte de Esri

Ir a opciones de descarga