Select to view content in your preferred language

I use the geopandas in arcgis pro and it does not update the operation performed

2332
2
Jump to solution
09-29-2022 03:03 PM
Labels (3)
DanielLeón81
Emerging Contributor

I am new in the programming area, I have done some code making use of sources on the web. That is why I am having trouble. In my query I have used Geopandas, pandas and numpy library to make modifications in the table of a Feature class. When I run the code it performs the operation I wrote but when I check the FC in arcgis pro it does not change. Could someone help me to solve this detail?

Code

capa_feature1 = gpd.read_file(r"D:\Proj_ASEAN\Proj_ArcGIS\Proj_ASEAN\SMOD.gdb")
operacion = lambda x,y,z: (x - y -z)
capa_feature1['SUM_Area_km2'] = np.where( capa_feature1['Area_km2'] == capa_feature1.iat[0,4], capa_feature1.iat[0,4], operacion(capa_feature1.iat[0,5],capa_feature1.iat[0,4],capa_feature1.iat[1,4]))
capa_feature1

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
Luke_Pinner
MVP Regular Contributor

You're reading the data in to a GeoDataFrame (gdf) which is in memory and no longer connected to the file geodatabase (FileGDB) FeatureClass (fc), so changing the gdf will not change the fc.

You need to write the gdf back to the FileGDB and overwrite the fc.

However, the OpenFileGDB driver that GeoPandas uses is read-only (unless you install the Esri FileGDB API and driver which can be difficult) so you are better off either using

  • ArcGIS methods (field calculator or arcpy.da.UpdateCursor) to do your calculation, or
  • writing out a different format (like a geopackage or geojson) and then using ArcGIS to import that to your FileGDB

View solution in original post

2 Replies
Luke_Pinner
MVP Regular Contributor

You're reading the data in to a GeoDataFrame (gdf) which is in memory and no longer connected to the file geodatabase (FileGDB) FeatureClass (fc), so changing the gdf will not change the fc.

You need to write the gdf back to the FileGDB and overwrite the fc.

However, the OpenFileGDB driver that GeoPandas uses is read-only (unless you install the Esri FileGDB API and driver which can be difficult) so you are better off either using

  • ArcGIS methods (field calculator or arcpy.da.UpdateCursor) to do your calculation, or
  • writing out a different format (like a geopackage or geojson) and then using ArcGIS to import that to your FileGDB
DanielLeón81
Emerging Contributor

Thank you so much 

0 Kudos