5

I use geopandas (which uses fiona) to read a GeoDataBase layer (using driver="OpenFileGDB") into a geodataframe for easy manipulation.

read_shp = gpd.read_file(GDB_file, layer=layer_choice)

That works well. I then rearrange the columns and do some data manipulation until I am happy with the data.

BUT I have no idea or if it is possible to write that geodataframe back into the GeoDataBase?

I tried: read_shp.to_file(GDB_file, layer=layer_choice) But that just creates a new shapefile in the wrong place.

Does anyone have a solution to this problem?

4

As with Fiona where you can specify the driver when you save a layer, you can do the same thing with GeoPandas (Writing Spatial Data)

GeoDataFrames can be exported to many different standard formats using the GeoDataFrame.to_file() method. For a full list of supported formats, type import fiona; fiona.supported_drivers.

In my case:

fiona.supported_drivers
{'ESRI Shapefile': 'raw', 'OpenFileGDB': 'r', ..., 'FileGDB': 'raw',...}
  • The OpenFileGDB driver is Read-only ('r', provides only read access to File Geodatabases)

  • If you want read and write access, you need to use the FileGDB driver ('raw')

If the driver is not installed, a solution is given in How to add support for FileGDB (Esri file gdb API) driver in fiona?

layer.to_file("result.gdf",driver="FileGDB") 
  • thanks for the response. Took a while to realize that I could get the FileGDB.dll file and installation through GIS Internals, rather than the ESRI route (which didn't work for me). Perhaps another thing to add is that you can overwrite a layer in a GDB, simply by adding specifying the layer target layer.to_file("result.gdb", layer="layer_name", driver="FileGDB"). – Jens Hiestermann Mar 10 '17 at 13:32
  • For that I get Unsupported Driver – user32882 May 2 at 9:40
-2

Have you seen this page from the USGS? It describes how to move tabular data back to a gdb using ArcPy. You might be able to tweak that...

It looks like geopandas does not write to GDB, due to that being an Esri proprietary format. You can run

import fiona pprint(fiona.supported_drivers)

to get the supported formats geopandas can write to:

 'ARCGEN': 'r',
 'AeronavFAA': 'r',
 'BNA': 'raw',
 'DGN': 'raw',
 'DXF': 'raw',
 'ESRI Shapefile': 'raw',
 'GPSTrackMaker': 'raw',
 'GPX': 'raw',
 'GeoJSON': 'rw',
 'Idrisi': 'r',
 'MapInfo File': 'raw',
 'OpenFileGDB': 'r',
 'PCIDSK': 'r',
 'SEGY': 'r',
 'SUA': 'r'

Would it be feasible for your process to export to a shapefile and then use arcpy.FeatureClassToGeodatabase_conversion to bring that into your GDB?

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.