I would like to open a .gdb
file which I received as .tar.gdb
. The unzipped folder contains the following elements in the figure. How can I open this in R
? It is a raster digital elevation model. I need the elevation values of the raster cells but do not have ArcGIS or related programs on my computer .
2 Answers
gdb files are ESRI GeoDatabase files, a proprietary format not suited for exchange with other applications.
There seems to be no GDAL raster driver for ESRI GeoDatabase files, and since R uses GDAL to load raster data, this won't work. You'll need to get the data in a GDAL supported format - for rasters a GeoTIFF is usually the solution.
There is a GDAL vector driver for ESRI GeoDatabase files, but that will only read in things like points, lines, and polygons, and I don't think it works on the latest version of the ESRI GeoDatabase file format.
-
2File geodatabase hasn't changed format since the 9.3-10.0 reorganization to XML metadata. The read/write Esri FGDB API does not support pre-10 layout, but the read-only open API does. Neither supports rasters.– VinceMay 1, 2020 at 12:22
As an update to @Spacedman's answer regarding vector files, the terra::vect
function makes reading .gdb files very easy for these filetypes:
DATA <- vect("/Path/File.gdb")
If the .gdb has multiple layers, there is also a layer
argument to specify which one you want. Otherwise it just defaults to the first layer alphabetically.
SO Questions related to the OP's issue: Importing raster with R from File Geodatabase? and How to extract raster from .gdb instead of empty polygons?
.tar.gdb
, but it seems to have extracted correctly (FGDB is not a file format, but a directory of file contents, as opposed to RDBMS tables). That's the good news. The bad news is that rasters are not directly supported by either the Esri or Open file geodatabase drivers. There may be some reverse-engineered extraction tools but you'd probably be better off with alternate input.