0

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.

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

This is the code that I made. Why are no changes shown in the attribute table of the feature class?

2
  • 1
    Are you writing the operation back to the .gdb file you're loading?
    – Encomium
    Sep 29 at 23:36
  • You're not actually attempting to make any modifications. Given that you're using Pro, using AddField (if necessary) and CalculateField with a !shape!.getArea(...) with appropriate parameters for the spatial reference is likely to be much more effective.
    – Vince
    Sep 30 at 2:59

1 Answer 1

0

From the Esri Community forum:

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
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.