Select to view content in your preferred language

While converting feature class to spatially enabled dataframe shape_length data is not populating ?

08-31-2023 02:43 AM
Labels (1)
New Contributor III

I am converting feature class to spatially enabled data frame using below code, after conversion shape_length field of a line layer is not getting populated. Only shape data is available ?


fc = os.path.join(geodatabase_path, layer_name)
sedf = arcgis.GeoAccessor.from_featureclass(fc)


0 Kudos
4 Replies
MVP Frequent Contributor

maybe a shapefile?

0 Kudos
New Contributor III

Sorry i could understand. Can you please elaborate ?

0 Kudos
MVP Esteemed Contributor

A shapefile might retain the shape_length field.  Shape_length and shape_area are maintained by featureclasses (eg in a gdb), but the code for 


may not maintain it.  Look at the code in your installation for

C:\... your install dir ...\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\geo\_io\

lines 666-682.  If you are running in an environment that has arcpy installed it attempts to read the length and area field... If your environment doesn't have arcpy installed, it will fail to retrieve them.

... sort of retired...
Esri Regular Contributor

I am seeing this too. Looks like the SHAPE_LENGTH field does not come through with GDB feature classes, at least. The good news, however, is it's simple to re-calculate the Shape length field:

sedf["length"] = sedf["SHAPE"].apply(lambda x: x.get_length("PLANAR", "METERS"))

More information on get_length options here.

0 Kudos