71 Opening Rasters from OpenFileGDB
Contents
71 Opening Rasters from OpenFileGDB#
This notebook illustrates how to open rasters that are stored in OpenFileGDBs. Currently, QGIS can open rasters from OpenFileGDBs since version 3.32. GeoPandas and the underlying fiona package are capable of opening vector files from OpenFileGDBs. It is not planned to support raster files (https://github.com/geopandas/geopandas/issues/2793). It is not planned to implement that feature into rasterio either (https://github.com/rasterio/rasterio/discussions/2914). Therefore, the decision was made
to implement the functionality to open rasters from OpenFileGDBs directly using the gdal
package.
Set File Paths and download Tutorial Data#
If you downloaded the latest GemGIS
version from the Github repository, append the path so that the package can be imported successfully. Otherwise, it is recommended to install GemGIS
via pip install gemgis
and import GemGIS
using import gemgis as gg
. In addition, the file path to the folder where the data is being stored is set. The tutorial data is downloaded using Pooch (https://www.fatiando.org/pooch/latest/index.html) and stored in the specified folder. Use
pip install pooch
if Pooch is not installed on your system yet.
[1]:
import warnings
warnings.filterwarnings("ignore")
import rasterio
from rasterio.plot import show
import gemgis as gg
[2]:
file_path ='data/71_Opening_Rasters_From_OpenFileGDB/'
Opening OpenFileGDB#
The OpenFileGDB can be opened using the GemGIS function gg.raster.read_raster_gdb(...)
. It will automatically save all included rasters to file. If there is no projection included in the OpenFileGDB, a crs
must be provided manually.
[4]:
gemgis.raster.read_raster_gdb(path=file_path + 'OpenFileGDB.gdb',
crs='EPSG:25832',
path_out=file_path)
RasterCenoman_Turon_top.tif successfully saved to file
RasterCenoman_Turon_m.tif successfully saved to file
RasterDevon_MK_m.tif successfully saved to file
RasterDevon_MK_top.tif successfully saved to file
RasterUKarb_m.tif successfully saved to file
RasterUKarb_top.tif successfully saved to file
RasterDGM.tif successfully saved to file
Opening Rasters using Rasterio#
The downloaded rasters can be opened and displayed using the rasterio package as any other raster.
[5]:
dem = rasterio.open(file_path + 'RasterDGM.tif')
dem
[5]:
<open DatasetReader name='data/71_Opening_Rasters_From_OpenFileGDB/RasterDGM.tif' mode='r'>
[6]:
show(dem);