I have a feature contained in a geodatabase that is larger than 2GB as an exported shapefile. I need to run an extract function in R to attribute the polygons with data from a raster file. Exporting the feature as a table is not a solution. How can I read feature classes contained within an Esri file geodatabase?


You can use rgdal to access feature classes in Esri file geodatabases.


# The input file geodatabase
fgdb <- "C:/path/to/your/filegeodatabase.gdb"

# List all feature classes in a file geodatabase
subset(ogrDrivers(), grepl("GDB", name))
fc_list <- ogrListLayers(fgdb)

# Read the feature class
fc <- readOGR(dsn=fgdb,layer="some_featureclass")

# Determine the FC extent, projection, and attribute information

# View the feature class
  • 2
    Previously, you could only do this if you downloaded the ESRI filegeodatabase API and compiled GDAL against it. If you use OSGeo4W to install GDAL there is an option to do this automatically. However, this may have changed in later releases of GDAL and it could now be native so, if I am incorrect I apologize. – Jeffrey Evans Jun 19 '15 at 20:00
  • 3
    @JeffreyEvans This is native now. – Aaron Jun 19 '15 at 20:04
  • 4
    While it is native for windows, it does not seem to be included currently for other platforms (at least Debian Jessie). – Cotton.Rockwood Apr 4 '16 at 3:21
  • 1
    +1 Works nicely. It helps to know that the layer argument may be omitted when there is just one feature class in the GDB. – whuber May 8 '18 at 20:29
  • 1
    For those who know nothing about gdb files, fgdb in this answer here is a directory and ogrListLayers() works on this directory... – MichaelChirico Dec 7 '18 at 8:26

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.