30 Opening GeoDataBases for GemGIS
Contents
30 Opening GeoDataBases for GemGIS#
A GeoDataBase folder containing raster or vector data or other type of formats can be opened using fiona and GeoPandas. The different layers can be listed using fiona and opened separately using GeoPandas to return GeoDataFrames for further processing.
Image Source: https://gisgeography.com/geodatabase-personal-file/ Map Source: https://open.nrw/dataset/11ed9860-d540-4f77-8af8-97cee14ce91f
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 gemgis as gg
file_path ='data/30_opening_geodatabases_for_gemgis/'
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
[2]:
gg.download_gemgis_data.download_tutorial_data(filename="30_opening_geodatabases_for_gemgis.zip", dirpath=file_path)
Downloading file '30_opening_geodatabases_for_gemgis.zip' from 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F30_opening_geodatabases_for_gemgis.zip' to 'C:\Users\ale93371\Documents\gemgis\docs\getting_started\tutorial\data\30_opening_geodatabases_for_gemgis'.
Load Layer Data#
The used GeoDataBase was downloaded from https://www.opengeodata.nrw.de/produkte/geologie/geologie/GK/ISGK100/ISGK100vektor/ and will be used under Datenlizenz Deutschland Namensnennung 2.0.
A list of the different layers within the GeoDataBase can be obtained using fionas listlayers(..)
function. Subsequently, the different layers in the GeoDataBase can be loaded as GeoDataFrames using GeoPandas.
[10]:
import geopandas as gpd
import fiona
layer_list = fiona.listlayers(file_path + 'ISGK100.gdb')
layer_list
[10]:
['GK100_Tektonik', 'GK100_Hauptschichten', 'GK100_Deckschichten']
Loading and Plotting different Layers of GeoDataBase#
[25]:
data = gpd.read_file(file_path + "ISGK100.gdb", driver='FileGDB', layer=layer_list[0])
data.head()
[25]:
TYP | DATUM | SHAPE_Length | geometry | |
---|---|---|---|---|
0 | Überschiebung, gesichert | 20140911 | 809.45 | MULTILINESTRING ((400321.058 5653696.880, 4001... |
1 | Überschiebung, gesichert | 20140911 | 695.09 | MULTILINESTRING ((399433.510 5653415.030, 3992... |
2 | Überschiebung, gesichert | 20140911 | 2021.76 | MULTILINESTRING ((402635.674 5654612.215, 4023... |
3 | Überschiebung, gesichert | 20140911 | 1016.71 | MULTILINESTRING ((403501.564 5651765.422, 4037... |
4 | Überschiebung, gesichert | 20140911 | 1085.76 | MULTILINESTRING ((404140.075 5652650.414, 4050... |
[24]:
import matplotlib.pyplot as plt
data.plot()
plt.grid()
[26]:
data = gpd.read_file(file_path + "ISGK100.gdb", driver='FileGDB', layer=layer_list[1])
data.head()
[26]:
ID | EINHEIT | SYMBOL | LITHOLOGIE | LITHOLOGIE_KURZ | STEINART | SYSTEM | SERIE | STUFE | LEGENDE | DATUM | SHAPE_Length | SHAPE_Area | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 4109 | Sprockhövel-Schichten | cnS | Schluff- und Tonstein, schwach bis stark sandi... | Tonstein, Schluffstein, Steinkohle | Festgestein | Karbon | Oberkarbon | Namur C | 4109, Sprockhövel-Schichten | 20140911 | 3008.74 | 172425.08 | MULTIPOLYGON (((352879.326 5697940.476, 352924... |
1 | 4109 | Sprockhövel-Schichten | cnS | Schluff- und Tonstein, schwach bis stark sandi... | Tonstein, Schluffstein, Steinkohle | Festgestein | Karbon | Oberkarbon | Namur C | 4109, Sprockhövel-Schichten | 20140911 | 2585.06 | 200323.96 | MULTIPOLYGON (((392856.502 5695841.097, 392721... |
2 | 4109 | Sprockhövel-Schichten | cnS | Schluff- und Tonstein, schwach bis stark sandi... | Tonstein, Schluffstein, Steinkohle | Festgestein | Karbon | Oberkarbon | Namur C | 4109, Sprockhövel-Schichten | 20140911 | 4025.19 | 300520.77 | MULTIPOLYGON (((358582.349 5698046.058, 358435... |
3 | 4109 | Sprockhövel-Schichten | cnS | Schluff- und Tonstein, schwach bis stark sandi... | Tonstein, Schluffstein, Steinkohle | Festgestein | Karbon | Oberkarbon | Namur C | 4109, Sprockhövel-Schichten | 20140911 | 2634.66 | 448870.72 | MULTIPOLYGON (((391719.954 5695960.055, 391591... |
4 | 4109 | Sprockhövel-Schichten | cnS | Schluff- und Tonstein, schwach bis stark sandi... | Tonstein, Schluffstein, Steinkohle | Festgestein | Karbon | Oberkarbon | Namur C | 4109, Sprockhövel-Schichten | 20140911 | 2260.89 | 143180.71 | MULTIPOLYGON (((375148.274 5696852.140, 375087... |
[22]:
import matplotlib.pyplot as plt
data.plot(column='SYSTEM', legend=True)
plt.grid()
[27]:
data = gpd.read_file(file_path + "ISGK100.gdb", driver='FileGDB', layer=layer_list[2])
data.head()
[27]:
ID | EINHEIT | SYMBOL | LITHOLOGIE | LITHOLOGIE_KURZ | STEINART | SYSTEM | SERIE | STUFE | LEGENDE | DATUM | SHAPE_Length | SHAPE_Area | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1132 | Auenlehm | Lf | Schluff und Ton, sandig, z.T. kalkhaltig, grau... | Schluff, Ton | Lockergestein | Quartär | Holozän | None | 1132, Auenlehm | 20140911 | 19229.40 | 1569937.10 | MULTIPOLYGON (((322257.871 5728988.642, 322320... |
1 | 1132 | Auenlehm | Lf | Schluff und Ton, sandig, z.T. kalkhaltig, grau... | Schluff, Ton | Lockergestein | Quartär | Holozän | None | 1132, Auenlehm | 20140911 | 3177.70 | 348742.93 | MULTIPOLYGON (((323863.620 5728974.644, 323892... |
2 | 1132 | Auenlehm | Lf | Schluff und Ton, sandig, z.T. kalkhaltig, grau... | Schluff, Ton | Lockergestein | Quartär | Holozän | None | 1132, Auenlehm | 20140911 | 5298.13 | 755121.53 | MULTIPOLYGON (((323481.893 5729792.005, 323501... |
3 | 1132 | Auenlehm | Lf | Schluff und Ton, sandig, z.T. kalkhaltig, grau... | Schluff, Ton | Lockergestein | Quartär | Holozän | None | 1132, Auenlehm | 20140911 | 2120.11 | 274024.58 | MULTIPOLYGON (((322560.368 5730041.085, 322782... |
4 | 1203 | Hanglehm, Hangschutt und Fließerde | hg | Schluff, tonig, sandig, grusig, steinig, braun... | Schluff | Lockergestein | Quartär | Pleistozän bis Holozän | None | 1203, Hanglehm, Hangschutt und Fließerde | 20140911 | 3788.10 | 859667.50 | MULTIPOLYGON (((472748.270 5713137.549, 472740... |
[19]:
import matplotlib.pyplot as plt
data.plot(column='SYSTEM', legend=True)
plt.grid()