问题
I am trying to load the data from the National Address Database provided by Transportation.gov into R. The data can be downloaded by anyone after accepting the disclaimer at this link: https://www.transportation.gov/gis/nad/disclaimer
I download the data, unzipped it into a directory I called data
and then tried to use rgdal
to list all the layers present in the data via:
fc_list<- rgdal::ogrListLayers("./data/NAD_20180215.gdb")
.
However, I cannot get rgdal
to return anything other than an error saying "Cannot Open Data Source"....
I am wondering how I would go about listing the layers present in the .gdb
folder as well as reading them into R?
I'm very grateful for any help. Thank you in advance.
-nate
回答1:
Following the suggestion here, using a full path to the gdb
folder helped in my case.
# check for package and install if needed
if(!require(rgdal)){
install.packages("rgdal", dep=T)
library(rgdal)
}
# full path to the geodatabase required
fgdb <- "C:/full/path/to/the/geodatabase.gdb"
# list all feature classes in a file geodatabase
subset(ogrDrivers(), grepl("GDB", name))
ogrListLayers(fgdb)
来源:https://stackoverflow.com/questions/52340442/cannot-open-data-source-gdb-in-r