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)
maybe a shapefile?
Sorry i could understand. Can you please elaborate ?
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
arcgis.GeoAccessor.from_featureclass
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\fileops.py
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.
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.