How does one calculate area for each feature in a Spatially Enabled Dataframe? I read it in from a shapefile and need the acreage of each feature. I also would like to store the area as a new column. This should be simple but I can't find a straight forward answer that works, I've referenced the two similar posts. Thank you!
sedf = pd.DataFrame.spatial.from_featureclass(myShapeFile)
Solved! Go to Solution.
You want to get a GeoSeriesAccessor and use its area property, maybe pipe that into a new field.
sedf = pd.DataFrame.spatial.from_featureclass(myShapeFile)
gsa = arcgis.features.GeoSeriesAccessor(sedf['SHAPE'])
# add column using insert
sedf.insert(0, 'the_area', gsa.area, True)
# alternatively, just add a new column at the end of the sedf
sedf['the_area'] = gsa.area
you could just calculate in the shapefile first
Please excuse the simplified example. I'm doing a bunch geoprocessing beforehand that I'm not showing, so I would like an updated calculation. I can do it in arcpy no problem but I am curious if the arcgis api has a way to do it.
You want to get a GeoSeriesAccessor and use its area property, maybe pipe that into a new field.
sedf = pd.DataFrame.spatial.from_featureclass(myShapeFile)
gsa = arcgis.features.GeoSeriesAccessor(sedf['SHAPE'])
# add column using insert
sedf.insert(0, 'the_area', gsa.area, True)
# alternatively, just add a new column at the end of the sedf
sedf['the_area'] = gsa.area
Exactly what I was looking for! Thank you!
I found this answer helpful.
Solved: Re: return geodesic area from spatial dataframe ar... - Esri Community