2

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 1.

Vince
20.5k16 gold badges49 silver badges65 bronze badges
asked May 1, 2020 at 11:24
1
  • 1
    There isn't any convention for passing file geodatabase as .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. Commented May 1, 2020 at 12:06

3 Answers 3

3

gdb files are ESRI GeoDatabase files, a proprietary format not suited for exchange with other applications.

Versions of GDAL before 3.7 have no GDAL raster driver for ESRI GeoDatabase files, and since R uses GDAL to load raster data, this won't work. If you have GDAL version 3.7 or more you should have the driver. This version was released in May 2023 but its possible your version is old. Even the latest rocker/geospatial:latest docker image is currently only linked with GDAL 3.4.1.

answered May 1, 2020 at 12:05
4
  • 2
    File 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. Commented May 1, 2020 at 12:22
  • 1
    Very outdated answer. QGIS can open .gdb files directly now, so it should be possible in R too! Commented Mar 17, 2024 at 22:34
  • @Tomas Really? What version of QGIS? Because the latest Ubuntu on my system only has GDAL 3.4.1 and that can't read rasters from an ESRI gdb. Perhaps you have >= 3.7 Commented Mar 19, 2024 at 15:12
  • @Spacedman QGIS 3.16.4-Hannover, Compiled against GDAL/OGR 3.1.4. Commented Jul 2, 2024 at 7:02
1

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?

answered Feb 25, 2022 at 16:49
0

As of June 2025, you can absolutely access raster data in a geodatabase (and without any proprietary ESRI software required)! You will need to have the latest spatial packages installed (if you need older versions, this may be less helpful for you), and in my case this worked on a Macbook using homebrew. I installed GDAL, GEOS, and PROJ (e.g., 'brew install gdal' after homebrew is set up). After this is done, make sure R is up to date, and then install terra (and sf, etc. if you want them) from source by running the below in R Studio or equivalent:

install.packages("terra", type = "source")

This will ensure that terra, etc., are linked properly with the spatial packages on your system (i.e., the homebrew installs). This step is really important; personally I have had the most sucess with doing installs from source rather than in the built-in R Studio package update manager.

Once this is done, you should be able to import the raster(s) you need from a geodatabase as follows:

gdb_path <- "/Users/your_user/Documents/your_dir/your_project.gdb"

your_raster <- rast(gdb_path, subds = "your_raster_layer")

answered Jun 20 at 20:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.