I am using the following instructions to read a TIGER/Line gdb into R.

The first commands work correctly and print out the feature classes:

fgdb <- "ACS_2014_5YR_BG_48_TEXAS.gdb"

subset(ogrDrivers(), grepl("GDB", name))
fc_list = ogrListLayers(fgdb)

 [1] "ACS_2014_5YR_BG_48_TEXAS"            "BG_METADATA_2014"                   
 [3] "X00_COUNTS"                          "X01_AGE_AND_SEX"                    
 [5] "X02_RACE"                            "X03_HISPANIC_OR_LATINO_ORIGIN"      
 [7] "X07_MIGRATION"                       "X08_COMMUTING"                      
[15] "X17_POVERTY"                         "X19_INCOME"                         
[17] "X20_EARNINGS"                        "X21_VETERAN_STATUS"                 
[19] "X22_FOOD_STAMPS"                     "X23_EMPLOYMENT_STATUS"              
[23] "X27_HEALTH_INSURANCE"                "X99_IMPUTATION"                     
[1] "OpenFileGDB"
[1] 24

However, when I try to import specific feature classes, the following error occurs:

> X01 = readOGR(dsn=fgdb,layer="X01_AGE_AND_SEX")
Error in readOGR(dsn = fgdb, layer = "X01_AGE_AND_SEX") : 
  no features found
In addition: Warning message:
In ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv,  :
  ogrInfo: all features NULL

These feature classes do not contain geometry data, which may be why there are no features found.

Is there workaround to read non-geometry feature classes into R from a gdb file ? The only solution I've found so far is to use GDAL command line tools to export the feature class to csv which would then be read into R, but I would like to cut out this middle step.

ogr2ogr -f CSV output.csv ACS_2014_5YR_BG_48_TEXAS.gdb X01_AGE_AND_SEX
  • I've just explored readOGR and we can do this at the R level by hacking out the bits that error and simply using the bits that reads the data frame. It's way overdue that someone finally did this. (It's not possible to do it in sf without recompiling). Feel free to get in touch. – mdsumner Feb 8 '17 at 6:26
  • Try this. gist.github.com/mdsumner/1112c8d89d99d1c13d0989320b612620 Let me know if you need help. Thanks for the trigger. – mdsumner Feb 8 '17 at 8:21

Your Answer

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

Browse other questions tagged or ask your own question.