GemGIS API Reference
Contents
GemGIS API Reference#
The API reference provides an overview of all functions and methods implemented in GemGIS.
gemgis.download_gemgis_data module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke.
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.download_gemgis_data.create_pooch(storage_url: str, files: List[str], target: str)#
Create pooch class to fetch files from a website.
- Parameters
storage_url (str) – Base URL for the remote data source.
files (List[str]) – A record of the files that are managed by this Pooch.
target (str, default:
''
) – The path to the local data storage folder, e.g.target='Documents/gemgis/'
.
- Returns
Pooch class.
- Return type
pooch.core.Pooch
See also
download_tutorial_data
Download the GemGIS data for each tutorial.
- gemgis.download_gemgis_data.download_tutorial_data(filename: str, dirpath: str = '', storage_url: str = 'https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F')#
Download the GemGIS data for each tutorial.
- Parameters
filename (str) – File name to be downloaded by pooch, e.g.
filename='file.zip'
.dirpath (str, default:
''
) – Path to the directory where the data is being stored, default to the directory where the notebook is located, e.g.dirpath='Documents/gemgis/'
.storage_url (str, default ‘https://rwth-aachen.sciebo.de/s/AfXRsZywYDbUF34/download?path=%2F’) – URL to the GemGIS data storage, default is the RWTH Aachen University Sciebo Cloud Storage.
See also
create_pooch
Create pooch class to fetch files from a website.
gemgis.gemgis module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- class gemgis.gemgis.GemPyData(model_name=None, crs=None, extent=None, resolution=None, interfaces=None, orientations=None, section_dict=None, customsections=None, dem=None, stack=None, surface_colors=None, is_fault=None, geolmap=None, basemap=None, faults=None, tectonics=None, raw_i=None, raw_o=None, raw_dem=None, wms=None, slope=None, hillshades=None, aspect=None, contours=None)#
Bases:
object
This class creates an object with attributes containing i.e. the interfaces or orientations that can directly be passed to a GemPy Model
The following attributes are available: - model_name: string - the name of the model - crs: string - the coordinate reference system of the model - interfaces: pd DataFrame - DataFrame containing the interfaces for the GemPy model - orientations: pd DataFrame - DataFrame containing the orientations for the GemPy model - extent: list - List containing the minx, maxx, miny, maxy, minz and maxz values - section_dict: dict - Dictionary containing the section_dict for custom sections for the GemPy model - customsections: GeoDataFrame containing the Linestrings or Endpoints of custom sections - resolution: list - List containing the x,y and z resolution of the model - dem: Union[string, array] - String containing the path to the DEM or array containing DEM values - stack: dict - Dictionary containing the layer stack associated with the model - surface_colors: dict - Dictionary containing the surface colors for the model - is_fault: list - list of surface that are classified as faults - geolmap: Union[GeoDataFrame,np.ndarray rasterio.io.Datasetreader] - GeoDataFrame or array containing the geological map either as vector or raster data set - basemap: Union[np.ndarray rasterio.io.Datasetreader] - Array or rasterio object containing a base map of the area - tectonics: GeoDataFrame - GeoDataFrame containing the LineStrings of fault traces - raw_i: GeoDataFrame - GeoDataFrame containing the raw interfaces point data - raw_o: GeoDataFrame - GeoDataFrame containing the raw orientations data - raw_dem: GeoDataFrame or np.ndarray - Raw dem data such as topographic lines or (gdf) or raster (array) - slope: np.ndarray - array containing the slope values of the DEM - hillshades: np.ndarray - array containing the color values of the hillshades - aspect: np.ndarray - array containing the aspect values of the DEM - faults: GeoDataFrame containing the Linestrings or vertices of faults - wms: np.ndarray containing data obtained from a WMS layer - contours: GeoDataFrame containing the contour lines of the model area
- set_extent(minx: Union[int, float] = 0, maxx: Union[int, float] = 0, miny: Union[int, float] = 0, maxy: Union[int, float] = 0, minz: Union[int, float] = 0, maxz: Union[int, float] = 0, **kwargs)#
Setting the extent for a model :param minx - float defining the left border of the model: :param maxx - float defining the right border of the model: :param miny - float defining the upper border of the model: :param maxy - float defining the lower border of the model: :param minz - float defining the top border of the model: :param maxz - float defining the bottom border of the model:
- Kwargs:
gdf - GeoDataFrame from which bounds the extent will be set
- Returns
extent - list with resolution values
- set_resolution(x: int, y: int, z: int)#
Setting the resolution for a model :param x - int defining the resolution in X direction: :param y - int defining the resolution in Y direction: :param z - int defining the resolution in Z direction:
- Returns
[x, y, z] - list with resolution values
- to_gempy_df(gdf: geopandas.geodataframe.GeoDataFrame, cat: str, **kwargs)#
Converting a GeoDataFrame into a Pandas DataFrame ready to be read in for GemPy :param gdf - gpd.geodataframe.GeoDataFrame containing spatial information: :param formation names and orientation values: :param cat - str/type of point data: :type cat - str/type of point data: interfaces or orientations
- Kwargs:
dem -
- Returns
df - interface or orientations DataFrame ready to be read in for GemPy
- to_section_dict(gdf: geopandas.geodataframe.GeoDataFrame, section_column: str = 'section_name', resolution=None)#
Converting custom sections stored in shape files to GemPy section_dicts :param gdf - gpd.geodataframe.GeoDataFrame containing the points or lines of custom sections: :param section_column - string containing the name of the column containing the section names: :param resolution - list containing the x: :param y resolution of the custom section:
- Returns
section_dict containing the section names, coordinates and resolution
- to_surface_color_dict(path: str, **kwargs)#
Create GemPy surface color dict from a qml file :param path: str/path to the qml file
- Returns
dict containing the surface color values for GemPy
- Return type
surface_color_dict
gemgis.misc module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke.
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.misc.get_meta_data(page: List[str]) list #
This function is used to extract the name, coordinates and depths, of one page with one well provided by the Geological Survey NRW. It is using the extracted page as string as input data and returns floats of the coordination data and the well name
- Parameters
page (List[str]) – List containing the strings of the borehole pdf
- Returns
data – List containing the extracted data values
- Return type
list
New in version 1.0.x.
Changed in version 1.1.7.
Adapting positions of coordinate values.
Example
>>> # Loading Libraries and split data >>> import gemgis as gg >>> # Split Data - from get_meta_data_df(...) >>> data = data.split() >>> data = '#'.join(data) >>> data = data.split('-Stammdaten') >>> data = [item.split('|')[0] for item in data] >>> data = [item.split('#') for item in data]
>>> # Filter out wells without Stratigraphic Column >>> data = [item for item in data if 'Beschreibung' in item]
>>> # Get Coordinates of data >>> coordinates = [get_meta_data(page=item) for item in data] >>> coordinates[0] ['DABO_196747', 'B.19ESCHWEILER', '19', 70.3, 32310019.32, 5633520.32, 130.0, 2521370.0, 5631910.0, 'Karbon', 'Eschweiler [TK 5103]', 'Eschweiler/Weißweiler', 'ungeprüfte Angabe aus dem Bohrarchiv', 'ungeprüfte Angabe aus dem Bohrarchiv', 'Exploration, Lagerstättenerkundung', 'Bohrung', '', 'vertraulich, offen nach Einzelfallprüfung;', 'Übertragung eines alten Archivbestandes', '1', 'Schichtdaten von guter Qualität; genaue stratigrafische Einstufung aufgestellt', '', '', 'Original-Schichtenverzeichnis liegt vor']
See also
load_pdf
Loading PDF data as string
get_meta_data_df
Getting the meta data of wells as DataFrame
get_stratigraphic_data
Getting the stratigraphic data of a well
get_stratigraphic_data_df
Getting the stratigraphic data of wells as DataFrame
- gemgis.misc.get_meta_data_df(data: str, name: str = 'GD', return_gdf: bool = True) Union[pandas.core.frame.DataFrame, geopandas.geodataframe.GeoDataFrame] #
Function to create a dataframe with coordinates and meta data of the different boreholes
- Parameters
data (str) – String containing the borehole data
name (str) – Prefix for custom index for boreholes, default ‘GD’, e.g.
name='GD'
return_gdf (bool) – Variable to return GeoDataFrame. Options include:
True
orFalse
, default set toTrue
- Returns
coordinates_dataframe_new – (Geo-)DataFrame containing the coordinates and meta data of the boreholes
- Return type
Union[pd.DataFrame, gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Changed in version 1.1.7.
Fixed bug in parsing PDF.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> content = gg.misc.load_pdf(path='file.pdf') >>> content 'Stammdaten - 2521/ 5631/ 1 - Bnum: 196747 . . Objekt / Name :B. 19 ESCHWEILER Bohrungs- / Aufschluß-Nr. :19 Archiv-Nr. : Endteufe [m] :70.30 Stratigraphie der Endteufe :Karbon . TK 25 :Eschweiler [TK 5103] Ort / Gemarkung :Eschweiler/Weißweiler GK R...'
>>> # Creating meta data DataFrame >>> gdf = gg.misc.get_meta_data_df(data=content, name='GD', return_gdf=True) >>> gdf Index DABO No. Name Number Depth X Y Z X_GK Y_GK ... Kind Procedure Confidentiality Record Type Lithlog Version Quality Drilling Period Remarks Availability Lithlog geometry 0 GD0001 DABO_196747 B.19ESCHWEILER 19 70.30 32310019.32 5633520.32 130.00 2521370.00 5631910.00 ... Bohrung vertraulich, offen nach Einzelfallprüfung; Übertragung eines alten Archivbestandes 1 Schichtdaten von guter Qualität; genaue strati... Original-Schichtenverzeichnis liegt vor POINT (32310019.320 5633520.320) 1 GD0002 DABO_196748 B.16ESCHWEILER 16 37.61 2310327.14 5632967.35 122.00 2521700.00 5631370.00 ... Bohrung vertraulich, offen nach Einzelfallprüfung; Übertragung eines alten Archivbestandes 1 Schichtdaten von guter Qualität; genaue strati... Original-Schichtenverzeichnis liegt vor POINT (32310327.140 5632967.350)
See also
load_pdf
Loading PDF data as string
get_meta_data
Getting the meta data of a well
get_stratigraphic_data
Getting the stratigraphic data of a well
get_stratigraphic_data_df
Getting the stratigraphic data of wells as DataFrame
- gemgis.misc.get_stratigraphic_data(text: list, symbols: List[Tuple[str, str]], formations: List[Tuple[str, str]]) list #
Function to retrieve the stratigraphic data from borehole logs
- Parameters
text (list) – String containing the borehole data
symbols (List[Tuple[str, str]]) – List of symbols to be removed from list of strings
formations (List[Tuple[str, str]]) – List of categorized formations
- Returns
data – List of extracted data values
- Return type
list
New in version 1.0.x.
Changed in version 1.1.7.
Fixed bug in parsing PDF.
Example
>>> # Loading Libraries and getting the stratigraphic data of borehole >>> import gemgis as gg >>> data = gg.misc.get_stratigraphic_data(text=text, symbols=symbols, formations=formations)
See also
load_pdf
Loading PDF data as string
get_meta_data
Getting the meta data of a well
get_meta_data_df
Getting the meta data of wells as DataFrame
get_stratigraphic_data_df
Getting the stratigraphic data of wells as DataFrame
- gemgis.misc.get_stratigraphic_data_df(data: str, name: str, symbols: List[Tuple[str, str]], formations: List[Tuple[str, str]], remove_last: bool = False, return_gdf: bool = True) Union[pandas.core.frame.DataFrame, geopandas.geodataframe.GeoDataFrame] #
Function to create a dataframe with coordinates and the stratigraphy of the different boreholes
- Parameters
data (list) – List containing the strings of the borehole log
name (str) – Name for index reference, e.g.
name='GD'
symbols (List[Tuple[str, str]]) – List of tuples with symbols to be filtered out
formations (List[Tuple[str, str]]) – List of tuples with formation names to be replaced
remove_last – Variable to remove the last value of each well. Options include:
True
orFalse
, default set toFalse
- Returns
strata – (Geo-)DataFrame containing the coordinates and the stratigraphy of the boreholes
- Return type
Union[pd.DataFrame, gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Changed in version 1.1.7.
Fixed bug in parsing PDF.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> content = gg.misc.load_pdf(path='file.pdf') >>> content 'Stammdaten - 2521/ 5631/ 1 - Bnum: 196747 . . Objekt / Name :B. 19 ESCHWEILER Bohrungs- / Aufschluß-Nr. :19 Archiv-Nr. : Endteufe [m] :70.30 Stratigraphie der Endteufe :Karbon . TK 25 :Eschweiler [TK 5103] Ort / Gemarkung :Eschweiler/Weißweiler GK R...'
>>> # Getting stratigraphic data DataFrame >>> gdf = gg.misc.get_stratigraphic_data_df(data=data, name='GD', symbols=symbols, formations=formations) >>> gdf Index Name X Y Z Altitude Depth formation geometry 0 GD0001 B.19ESCHWEILER 32310019.32 5633520.32 125.30 130.00 70.30 Quaternary POINT (32310019.320 5633520.320) 1 GD0001 B.19ESCHWEILER 32310019.32 5633520.32 66.50 130.00 70.30 Miocene POINT (32310019.320 5633520.320) 2 GD0001 B.19ESCHWEILER 32310019.32 5633520.32 60.90 130.00 70.30 Oligocene POINT (32310019.320 5633520.320)
See also
load_pdf
Loading PDF data as string
get_meta_data
Getting the meta data of a well
get_meta_data_df
Getting the meta data of wells as DataFrame
get_stratigraphic_data
Getting the stratigraphic data of a well
- gemgis.misc.load_formations(path: str) list #
Loading formations for extraction of borehole data
- Parameters
path (str) – Path to the file containing the symbols for extracting the borehole data, e.g.
path='boreholes.txt'
- Returns
formations – List of tuples with formations to be extracted
- Return type
list
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> formations = gg.misc.load_formations(paths='formations.txt')
>>> # Inspecting the formations >>> formations [('UnterdevonKalltalFormation', 'KalltalFM'), ('Bölling', 'Quaternary'), ('AtlantikumAuenterrassen[TalterrasseInselterrasse]', 'Quaternary'), ('nullLöss', 'Quaternary'), ('Waal', 'Quaternary')]
- gemgis.misc.load_pdf(path: str, save_as_txt: bool = True) str #
Load PDF file containing borehole data.
- Parameters
path (str) – Name of the PDF file, e.g.
path='file.pdf'
.save_as_txt (bool, default:
True
) – Variable to save the extracted data as txt file. Options include:True
orFalse
.
- Returns
Extracted page content from borehole data.
- Return type
str
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> content = gg.misc.load_pdf(path='file.pdf') >>> content 'Stammdaten - 2521/ 5631/ 1 - Bnum: 196747 . . Objekt / Name :B. 19 ESCHWEILER Bohrungs- / Aufschluß-Nr. :19 Archiv-Nr. : Endteufe [m] :70.30 Stratigraphie der Endteufe :Karbon . TK 25 :Eschweiler [TK 5103] Ort / Gemarkung :Eschweiler/Weißweiler GK R...'
See also
get_meta_data
Get the meta data of a well.
get_meta_data_df
Get the meta data of wells as DataFrame.
get_stratigraphic_data
Get the stratigraphic data of a well.
get_stratigraphic_data_df
Get the stratigraphic data of wells as DataFrame.
- gemgis.misc.load_symbols(path: str) list #
Loading symbols for extraction of borehole data
- Parameters
path (str) – Path to the file containing the symbols for extracting the borehole data, e.g.
path='boreholes.txt'
- Returns
symbols – List of tuples with symbols to be removed
- Return type
list
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> symbols = gg.misc.load_symbols(paths='symbols.txt')
>>> # Inspecting the symbols >>> symbols [('.m ', ''), (', ', ''), ('; ', ''), (': ', ''), ('/ ', ''), ('? ', ''), ('! ', ''), ('-"- ', ''), ('" ', ''), ('% ', ''), ('< ', ''), ('> ', ''), ('= ', ''), ('~ ', ''), ('_ ', ''), ('° ', ''), ("' ", '')]
gemgis.postprocessing module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.postprocessing.calculate_dip_and_azimuth_from_mesh(mesh: pyvista.core.pointset.PolyData) pyvista.core.pointset.PolyData #
Calculating dip and azimuth values for a mesh and setting them as scalars for subsequent plotting
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista Mesh for which the dip and the azimuth will be calculated
- Returns
mesh – PyVista Mesh with appended dips and azimuths
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
- gemgis.postprocessing.clip_fault_of_gempy_model(geo_model, fault: str, which: str = 'first', buffer_first: Union[int, float] = None, buffer_last: Union[int, float] = None, i_size: Union[int, float] = 1000, j_size: Union[int, float] = 1000, invert_first: bool = True, invert_last: bool = False) Union[pyvista.core.pointset.PolyData, List[pyvista.core.pointset.PolyData]] #
Clip fault of a GemPy model.
- Parameters
geo_model (gp.core.model.Project) – GemPy Model containing the faults.
fault (str) – String or list of strings containing the name of faults to be clipped, e.g.
faults='Fault1'
.which (str, default:
'first'
) – Parameter to decide which end of the faults to clip. Options include'first'
,'last'
, or both, e.g.'which='first'
.buffer_first (Union[int, float]) – Int or float value or list of values to clip the fault/s behind the first interface point, e.g.
'buffer_first=500'
.buffer_last (Union[int, float]) – Int or float value or list of values to clip the fault/s behind the last interface point, e.g.
'buffer_last=500'
.i_size (Union[int, float]) – Size of the plane in the i direction.
j_size (Union[int, float]) – Size of the plane in the j direction.
invert_first (bool, default:
'True'
) – Invert clipping for first plane.invert_last (bool, default:
'False'
) – Invert clipping for second plane.
- Returns
Clipped faults.
- Return type
pv.core.pointset.PolyData
New in version 1.1.
See also
create_plane_from_interface_and_orientation
Create PyVista plane from GemPy interface and orientations DataFrames.
translate_clipping_plane
Translate clipping plane.
Example
- gemgis.postprocessing.create_attributes(keys: list, values: list) list #
Creating a list of attribute dicts
- Parameters
key (list) – List of keys to create the attributes with
values (list) – List of values for the dicts
- Returns
dicts – List containing the attribute dicts
- Return type
list
New in version 1.0.x.
- gemgis.postprocessing.create_plane_from_interface_and_orientation_dfs(df_interface: pandas.core.frame.DataFrame, df_orientations: pandas.core.frame.DataFrame, i_size: Union[int, float] = 1000, j_size: Union[int, float] = 1000) pyvista.core.pointset.PolyData #
Create PyVista plane from GemPy interface and orientations DataFrames.
- Parameters
df_interface (pd.DataFrame) – GemPy Pandas DataFrame containing the interface point for the plane creation.
df_orientations (pd.DataFrame) – GemPy Pandas Dataframe containing the orientations for the plane creation.
i_size (Union[int, float]) – Size of the plane in the i direction.
j_size (Union[int, float]) – Size of the plane in the j direction.
- Returns
plane (pv.core.pointset.PolyData) – Plane for clipping the fault.
azimuth (Union[int, float]) – Azimuth of the fault.
New in version 1.1.
See also
clip_fault_of_gempy_model
Clip fault of a GemPy model.
translate_clipping_plane
Translate clipping plane.
Example
- gemgis.postprocessing.create_subelement(parent: xml.etree.ElementTree.Element, name: str, attrib: dict)#
Creating Subelement
- Parameters
parent (xml.etree.ElementTree.Element) – Parent Element
name (str) – Name of the Element
attrib (dict) – Dict containing the attributes of the element
New in version 1.0.x.
- gemgis.postprocessing.create_symbol(parent: xml.etree.ElementTree.Element, color: str, symbol_text: str, outline_width: str = '0.26', alpha: str = '1')#
Creating symbol entry
- Parameters
parent (xml.etree.ElementTree.Element) – Parent Element
color (str) – RGBA values provided as string
outline_width (str) – Outline width of the polygons
alpha (str) – Opacity value
symbol_text (str) – Number of the symbol
New in version 1.0.x.
- gemgis.postprocessing.crop_block_to_topography(geo_model) pyvista.core.pointset.UnstructuredGrid #
Cropping GemPy solutions block to topography
- Parameters
geo_model (gp.core.model.Project) –
- Returns
grid
- Return type
pv.core.pointset.UnstructuredGrid
New in version 1.0.x.
- gemgis.postprocessing.extract_borehole(geo_model, geo_data: gemgis.gemgis.GemPyData, loc: List[Union[int, float]], **kwargs)#
Extracting a borehole at a provided location from a recalculated GemPy Model
- Parameters
geo_model (gp.core.model.Project) – Previously calculated GemPy Model
geo_data (gemgis.GemPyData) – GemGIS GemPy Data class used to calculate the previous model
loc (list) – List of X and Y point pairs representing the well location
zmax (Union[int, float]) – Value indicating the maximum depth of the well, default is minz of the previous model
res (int) – Value indicating the resolution of the model in z-direction
- Returns
sol (np.ndarray)
well_model (gp.core.model.Project)
depth_dict (dict)
New in version 1.0.x.
- gemgis.postprocessing.extract_lithologies(geo_model, extent: list, crs: Union[str, pyproj.crs.crs.CRS]) geopandas.geodataframe.GeoDataFrame #
Extracting the geological map as GeoDataFrame
- Parameters
geo_model (gp.core.model.Project) – GemPy geo_model
extent (list) – Extent of geo_model
crs (Union[str, pyproj.crs.crs.CRS]) – Coordinate References System
- Returns
lith – Lithologies of the geological map
- Return type
gpd.geodataFrame.GeoDataFrame
New in version 1.0.x.
- gemgis.postprocessing.extract_orientations_from_mesh(mesh: pyvista.core.pointset.PolyData, crs: Union[str, pyproj.crs.crs.CRS]) geopandas.geodataframe.GeoDataFrame #
Extracting orientations (dip and azimuth) from PyVista Mesh
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista Mesh from which the orientations will be extracted
crs (Union[str, pyproj.crs.crs.CRS]) – Coordinate reference system of the returned GeoDataFrame,
crs='EPSG:4326'
- Returns
gdf_orientations – GeoDataFrame consisting of the orientations
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
- gemgis.postprocessing.save_model(geo_model, path)#
Function to save the model parameters to files
- Parameters
geo_model (gp.core.model.Project) – GemPy model to be saved
path (str) – Path/folder where data is stored, e.g.
path='model/'
New in version 1.0.x.
- gemgis.postprocessing.save_qgis_qml_file(gdf: geopandas.geodataframe.GeoDataFrame, value: str = 'formation', color: str = 'color', outline_width: Union[int, float] = 0.26, alpha: Union[int, float] = 1, path: str = '')#
Creating and saving a QGIS Style File/QML File based on a GeoDataFrame
- Parameters
gdf (gpd.geoDataFrame.GeoDataFrame) – GeoDataFrame containing the Polygons, formation names and color values
value (str) – Name of the column used to categorize the layer
color (str) – Name of the column containing the color values
outline_width (Union[int, float]) – Outline width of the polygons
path (str) – Path where the QML file will be stored
New in version 1.0.x.
- gemgis.postprocessing.translate_clipping_plane(plane: pyvista.core.pointset.PolyData, azimuth: Union[int, float, numpy.int64], buffer: Union[int, float]) pyvista.core.pointset.PolyData #
Translate clipping plane.
- Parameters
plane (pv.core.pointset.PolyData) – Clipping Plane.
azimuth (Union[int, float, np.int64]) – Orientation of the Fault.
buffer (Union[int, float, type(None)]) – Buffer to translate the clipping plane along the strike of the fault.
- Returns
Translated clipping plane.
- Return type
pv.core.pointset.PolyData
New in version 1.1.
See also
create_plane_from_interface_and_orientation
Create PyVista plane from GemPy interface and orientations DataFrames.
clip_fault_of_gempy_model
Clip fault of a GemPy model.
Example
gemgis.raster module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann
GemGIS is a Python-based, open-source geographic information processing library. It is capable of preprocessing spatial data such as vector data (shape files, geojson files, geopackages), raster data, data obtained from WMS services or XML/KML files. Preprocessed data can be stored in a dedicated Data Class to be passed to the geomodeling package GemPy in order to accelerate to model building process.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.raster.calculate_aspect(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, band_no: int = 1) numpy.ndarray #
Calculating the aspect based on a digital elevation model/raster
- Parameters
raster (np.ndarray, rasterio.io.DatasetReader) – NumPy array or rasterio object containing the elevation data
extent (List[Union[int, float]]) – List of minx, maxx, miny and maxy coordinates representing the raster extent if raster is passed as array, e.g.
extent=[0, 972, 0, 1069]
band_no (int) – Band number of the raster to be used for calculating the hillshades, e.g.
band_no=1
, default is1
- Returns
aspect – NumPy array containing the aspect values
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Calculating the aspect of a raster >>> aspect = gg.raster.calculate_aspect(raster=raster) >>> aspect array([[246.37328, 245.80156, 245.04022, ..., 269.87958, 270.11377, 270.32904],....], dtype=float32)
See also
calculate_hillshades
Calculating the hillshades of a raster
calculate_slope
Calculating the slope of a raster
calculate_difference
Calculating the difference between two rasters
- gemgis.raster.calculate_difference(raster1: Union[numpy.ndarray, rasterio.io.DatasetReader], raster2: Union[numpy.ndarray, rasterio.io.DatasetReader], flip_array: bool = False) numpy.ndarray #
Calculating the difference between two rasters
- Parameters
raster1 (np.ndarray) – First array
raster2 (np.ndarray) – Second array
flip_array (bool) – Variable to flip the array. Options include:
True
orFalse
, default set toFalse
- Returns
array_diff – Array containing the difference between array1 and array2
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and Files >>> import gemgis as gg >>> import rasterio >>> raster1 = rasterio.open(fp='raster1.tif') >>> raster2 = rasterio.open(fp='raster2.tif')
>>> # Calculate difference between two rasters >>> difference = gg.raster.calculate_difference(raster1=raster1, raster2=raster2) >>> difference array([[-10., -10., -10., ..., -10., -10., -10.],.....], dtype=float32)
See also
calculate_hillshades
Calculating the hillshades of a raster
calculate_slope
Calculating the slope of a raster
calculate_aspect
Calculating the aspect of a raster
- gemgis.raster.calculate_hillshades(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, azdeg: Union[int, float] = 225, altdeg: Union[int, float] = 45, band_no: int = 1) numpy.ndarray #
Calculating Hillshades based on digital elevation model/raster
- Parameters
raster (np.ndarray, rasterio.io.DatasetReader) – NumPy array or rasterio object containing the elevation data
extent (List[Union[int, float]]) – List of minx, maxx, miny and maxy points representing the extent of the raster if raster is passed as array, e.g.
extent=[0, 972, 0, 1069]
azdeg (Union[int, float]) – Azimuth value for the light source direction, e.g.
azdeg=225
, default is225
degreesaltdeg (Union[int, float]) – Altitude value for the light source, e.g.
altdeg=45
, default is45
degreesband_no (int) – Band number of the raster to be used for calculating the hillshades, e.g.
band_no=1
, default is1
- Returns
hillshades – NumPy array containing the hillshade color values
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Calculating hillshades from raster >>> hillshades = gg.raster.calculate_hillshades(raster=raster) >>> hillshades array([[250.04817, 250.21147, 250.38988, ..., 235.01764, 235.0847 , 235.0842 ], ....], dtype=float32)
See also
calculate_slope
Calculating the slope of a raster
calculate_aspect
Calculating the aspect of a raster
calculate_difference
Calculating the difference between two rasters
- gemgis.raster.calculate_slope(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, band_no: int = 1) numpy.ndarray #
Calculating the slope based on digital elevation model/raster
- Parameters
raster (np.ndarray, rasterio.io.DatasetReader) – NumPy array or rasterio object containing the elevation data
extent (List[Union[int, float]]) – List of minx, maxx, miny and maxy coordinates representing the raster extent if raster is passed as array, e.g.
extent=[0, 972, 0, 1069]
band_no (int) – Band number of the raster to be used for calculating the hillshades, e.g.
band_no=1
, default is1
- Returns
slope – NumPy array containing the slope values
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Calculating the slope of a raster >>> slope = gg.raster.calculate_slope(raster=raster) >>> slope array([[37.092472, 36.95191 , 36.649662, ..., 21.988844, 22.367924, 22.584248],....], dtype=float32)
See also
calculate_hillshades
Calculating the hillshades of a raster
calculate_aspect
Calculating the aspect of a raster
calculate_difference
Calculating the difference between two rasters
- gemgis.raster.clip_by_bbox(raster: Union[rasterio.io.DatasetReader, numpy.ndarray], bbox: List[Union[int, float]], raster_extent: List[Union[int, float]] = None, save_clipped_raster: bool = False, path: str = 'raster_clipped.tif', overwrite_file: bool = False, create_directory: bool = False) numpy.ndarray #
Clipping a rasterio raster or np.ndarray by a given extent
- Parameters
raster (Union[rasterio.io.DatasetReader, np.ndarray]) – Array or Rasterio object to be clipped
bbox (List[Union[int, float]]) – Bounding box of minx, maxx, miny, maxy values to clip the raster, e.g.
bbox=[0, 972, 0, 1069]
raster_extent (List[Union[int, float]]) – List of float values defining the extent of the raster, default None, e.g.
raster_extent=[0, 972, 0, 1069]
save_clipped_raster (bool) – Variable to save the raster after clipping. Options include:
True
orFalse
, default set toFalse
path (str) – Path where the raster is saved, e.g.
path='raster_clipped.tif'
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
raster_clipped – Clipped array after clipping
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif') >>> raster.read(1).shape (275, 250)
>>> # Creating bounding box and defining raster extent >>> bbox = [250, 500, 250, 500] >>> raster_extent = [0, 972, 0, 1069]
>>> # Clipping raster by bounding box >>> raster_clipped = gg.raster.clip_by_bbox(raster=raster, bbox=bbox, raster_extent=raster_extent) >>> raster_clipped.shape (65, 65)
See also
clip_by_polygon
Clipping raster by a Shapely Polygon
- gemgis.raster.clip_by_polygon(raster: Union[rasterio.io.DatasetReader, numpy.ndarray], polygon: shapely.geometry.polygon.Polygon, raster_extent: List[Union[int, float]] = None, save_clipped_raster: bool = False, path: str = 'raster_clipped.tif', overwrite_file: bool = False, create_directory: bool = False) numpy.ndarray #
Clipping/masking a rasterio raster or np.ndarray by a given shapely Polygon
- Parameters
raster (Union[rasterio.io.DatasetReader, np.ndarray]) – Array or Rasterio object to be clipped
polygon (shapely.geometry.polygon.Polygon) – Shapely polygon defining the extent of the data, e.g.
polygon = Polygon([(0, 0), (1, 1), (1, 0)])
raster_extent (List[Union[int, float]]) – List of float values defining the extent of the raster, default None, e.g.
raster_extent=[0, 972, 0, 1069]
save_clipped_raster (bool) – Variable to save the raster after clipping, default False. Options include:
True
orFalse
, default set toFalse
path (str) – Path where the raster is saved, e.g.
path='raster_clipped.tif
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
raster_clipped – Clipped array after clipping
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> from shapely.geometry import Polygon >>> raster = rasterio.open(fp='raster.tif') >>> raster.read(1).shape (275, 250)
>>> # Creating Shapely Polygon and defining raster extent >>> polygon = Polygon([(250, 250), (500, 250), (500, 500), (250, 500)]) >>> raster_extent = [0, 972, 0, 1069]
>>> # Clipping the raster by a Shapely Polygon >>> raster_clipped = gg.raster.clip_by_polygon(raster=raster, polygon=polygon, raster_extent=raster_extent) >>> raster_clipped.shape (65, 65)
See also
clip_by_bbox
Clipping raster by a Bounding Box
- gemgis.raster.create_filepaths(dirpath: str, search_criteria: str, create_directory: bool = False) List[str] #
Retrieving the file paths of the tiles to load and to process them later
- Parameters
dirpath (str) – Path to the folder where tiles are stored, e.g.
dirpath='Documents/images/'
search_criteria (str) – Name of the files including file ending, use
*
for autocompletion by Python, e.g.search_criteria='tile*.tif'
create_directory (bool) – Variable to create a new directory if directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
filepaths – List of file paths
- Return type
List[str]
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg
>>> # Defining filepath >>> filepath = 'Documents/images/'
>>> # Creating list of filepaths based on search criteria >>> filepaths = gg.raster.create_filepaths(dirpath=filepath, search_criteria='tile*.tif') >>> filepaths ['Documents/images//tile_292000_294000_5626000_5628000.tif', 'Documents/images//tile_292000_294000_5628000_5630000.tif', 'Documents/images//tile_292000_294000_5630000_5632000.tif', 'Documents/images//tile_294000_296000_5626000_5628000.tif']
- gemgis.raster.create_src_list(dirpath: str = '', search_criteria: str = '', filepaths: List[str] = None, create_directory: bool = False) List[rasterio.io.DatasetReader] #
Creating a list of source files
- Parameters
dirpath (str) – Path to the folder where tiles are stored, e.g.
dirpath='Documents/images/'
search_criteria (str) – Name of the files including file ending, use * for autocompletion by Python, e.g.
search_criteria='tile*.tif'
filepaths (List[str]) – List of strings containing file paths
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
src_files – List containing the loaded rasterio datasets
- Return type
List[rasterio.io.DatasetReader]
New in version 1.0.x.
Example
>>> # Importing Libraries >>> import gemgis as gg
>>> # Defining filepath >>> filepath = 'Documents/images/'
>>> # Creating List of filepaths >>> filepaths = gg.raster.create_filepaths(dirpath=filepath, search_criteria='tile*.tif') >>> filepaths ['Documents/images//tile_292000_294000_5626000_5628000.tif', 'Documents/images//tile_292000_294000_5628000_5630000.tif', 'Documents/images//tile_292000_294000_5630000_5632000.tif', 'Documents/images//tile_294000_296000_5626000_5628000.tif']
>>> # Creating list of loaded rasterio objects >>> src_list = gg.raster.create_src_list(filepaths=filepaths) >>> src_list [<open DatasetReader name='Documents/images/tile_292000_294000_5626000_5628000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_292000_294000_5628000_5630000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_292000_294000_5630000_5632000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_294000_296000_5626000_5628000.tif' mode='r'>,
- gemgis.raster.extract_contour_lines_from_raster(raster: Union[rasterio.io.DatasetReader, numpy.ndarray, str], interval: int, extent: Union[Sequence[float], None, Sequence[int]] = None, target_crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None) geopandas.geodataframe.GeoDataFrame #
Extracting contour lines from raster with a provided interval.
- Parameters
raster (Union[rasterio.io.DatasetReader, np.ndarray, str]) – Raster from which contour lines are extracted
extent (Optional[Sequence[float, int]]) – If raster given as array: values (minx, maxx, miny, maxy) to define raster extent, e.g.
extent =[0, 972, 0, 1069]
target_crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – If raster given as array: name of the CRS is required to project values to coordinates of GeoDataFrame, e.g.
target_crs='EPSG:4647'
interval (int) – Given interval for the extracted contour lines, e.g.
interval=50
- Returns
gdf_lines – GeoDataFrame containing the extracted contour lines as LineStrings
- Return type
gpd.GeoDataFrame
New in version 1.0.x.
- gemgis.raster.merge_tiles(src_files: List[rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, res: int = None, nodata: Union[float, int] = None, precision: int = None, indices: int = None, method: str = 'first') Tuple[numpy.ndarray, affine.Affine] #
Merging downloaded tiles to mosaic
- Parameters
src_files (List[rasterio.io.DatasetReader]) – List of rasterio datasets to be merged
extent (List[Union[float, int]]) – Bounds of the output image (left, bottom, right, top). If not set, bounds are determined from bounds of input rasters, e.g.
extent=[0, 972, 0, 1069]
, default isNone
res (int) – Output resolution in units of coordinate reference system. If not set, the resolution of the first raster is used. If a single value is passed, output pixels will be square. e.g.
res=50
, default isNone
nodata (Union[float, int]) – nodata value to use in output file. If not set, uses the nodata value in the first input raster, e.g.
nodata=9999.0
, default isNone
precision (int) – Number of decimal points of precision when computing inverse transform, e.g.
precision=2
, default isNone
indices (int) – Bands to read and merge, e.g.
indices=1
, default isNone
method (str) – Method on how to merge the tiles, e.g.
method='first'
, default is'first'
- Returns
mosaic (np.ndarray) – Array containing the merged tile data
transform (affine.Affine) – Affine Transform of the merged tiles
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg
>>> # Creating filepath >>> filepath = 'Documents/images/'
>>> # Creating list of filepaths >>> filepaths = gg.raster.create_filepaths(dirpath=filepath, search_criteria='tile*.tif') >>> filepaths ['Documents/images//tile_292000_294000_5626000_5628000.tif', 'Documents/images//tile_292000_294000_5628000_5630000.tif', 'Documents/images//tile_292000_294000_5630000_5632000.tif', 'Documents/images//tile_294000_296000_5626000_5628000.tif']
>>> # Creating list of loaded rasterio objects >>> src_list = gg.raster.create_src_list(filepaths=filepaths) >>> src_list [<open DatasetReader name='Documents/images/tile_292000_294000_5626000_5628000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_292000_294000_5628000_5630000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_292000_294000_5630000_5632000.tif' mode='r'>, <open DatasetReader name='Documents/images/tile_294000_296000_5626000_5628000.tif' mode='r'>,
>>> # Merging tiles >>> mosaic, transform = gg.raster.merge_tiles(src_files=src_list)
>>> # Inspecting the mosaic data >>> mosaic array([[200.72, 200.73, 200.72, ..., 204.42, 204.45, 204.45], [200.74, 200.74, 200.75, ..., 204.43, 204.44, 204.48] [200.76, 200.76, 200.76, ..., 204.42, 204.48, 204.5 ], ..., [329.15, 328.86, 328.74, ..., 242.45, 242.38, 242.28], [329.29, 329.06, 328.87, ..., 242.45, 242.39, 242.31], [329.47, 329.3 , 329.09, ..., 242.42, 242.37, 242.32]], dtype=float32)
>>> # Inspecting the transform of the mosaic >>> transform Affine(1.0, 0.0, 292000.0, 0.0, -1.0, 5632000.0)
- gemgis.raster.read_asc(path: Union[str, pathlib.Path]) dict #
Function to read GoCAD .asc files
- Parameters
path (Union[str, Path]) – Path to asc file, e.g.
path='raster.asc'
- Returns
data – Dict containing the array data, the extent, resolution and nodata_val of the raster
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and Files >>> import gemgis as gg >>> data = gg.raster.read_asc('raster.asc')
>>> # Inspecting the content of the dict, here we only see the nodata_vals for now >>> data['Data'] array([[-99999., -99999., -99999., ..., -99999., -99999., -99999.], [-99999., -99999., -99999., ..., -99999., -99999., -99999.], [-99999., -99999., -99999., ..., -99999., -99999., -99999.], ..., [-99999., -99999., -99999., ..., -99999., -99999., -99999.], [-99999., -99999., -99999., ..., -99999., -99999., -99999.], [-99999., -99999., -99999., ..., -99999., -99999., -99999.]])
>>> data['Extent'] [-42250, 306000, 279000, 867000]
>>> data['Resolution'] 250
>>> data['Nodata_val'] -99999
- gemgis.raster.read_msh(path: Union[str, pathlib.Path]) Dict[str, numpy.ndarray] #
Function to read Leapfrog .msh files - https://help.leapfrog3d.com/Geo/4.3/en-GB/Content/meshes/meshes.htm
- Parameters
path (Union[str, Path]) – Path to msh file, e.g.
path='mesh.msh'
- Returns
data – Dict containing the mesh data
- Return type
Dict[str, np.ndarray]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> data = gg.raster.read_msh('mesh.msh') >>> data {'Tri': array([[ 0, 1, 2], [ 0, 3, 1], [ 4, 3, 0], ..., [53677, 53672, 53680], [53679, 53677, 53680], [53673, 53672, 53677]]), 'Location': array([[ 1.44625109e+06, 5.24854344e+06, -1.12743862e+02], [ 1.44624766e+06, 5.24854640e+06, -1.15102216e+02], [ 1.44624808e+06, 5.24854657e+06, -1.15080548e+02], ..., [ 1.44831008e+06, 5.24896679e+06, -1.24755449e+02], [ 1.44830385e+06, 5.24896985e+06, -1.33694397e+02], [ 1.44829874e+06, 5.24897215e+06, -1.42506587e+02]])}
- gemgis.raster.read_raster_gdb(path: str, crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None, path_out: str = '')#
Read Raster from OpenFileGDB.
- Parameters
path (str) – Path to the OpenFileGDB.
crs (str, pyproj.crs.crs.CRS, rasterio.crs.CRS) – Coordinate Reference System of the dataset.
path_out (str) – Output folder path
New in version 1.1.1.
- gemgis.raster.read_ts(path: Union[str, pathlib.Path]) Tuple[list, list] #
Function to read GoCAD .ts files
- Parameters
path (Union[str, Path]) – Path to ts file, e.g.
path='mesh.ts'
- Returns
vertices (list) – Pandas DataFrames containing the vertex data
faces (list) – NumPy arrays containing the faces data
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> vertices, faces = gg.raster.read_ts('mesh.ts')
>>> # Inspecting the vertices >>> vertices id X Y Z 0 0 297077.41 5677487.26 -838.50 1 1 297437.54 5676992.09 -816.61
>>> # Inspecting the faces >>> faces array([[ 0, 1, 2], [ 3, 2, 4], [ 1, 5, 6],..., [40335, 40338, 40336], [40339, 40340, 40341], [40341, 40342, 40339]])
- gemgis.raster.read_zmap(path: Union[str, pathlib.Path]) dict #
Reading Petrel ZMAP Files
- Parameters
path (Union[str, Path]) – Path to dat file, e.g.
path='raster.dat'
- Returns
data – Dict containing the array data, the extent, array dimension, resolution and nodata_val of the raster
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> data = gg.raster.read_zmap(path='file.dat')
>>> # Inspecting the content of the dict, here we only see the nodata_vals for now >>> data {'Data': array([[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]), 'Extent': [-42250.0, 278750.0, 306000.0, 866750.0], 'Resolution': [250.0, 250.0], 'Nodata_val': 0.1000000E+31, 'Dimensions': (2244, 1285), 'CRS': 'Amersfoort * EPSG-Nld / RD New [28992,1672]', 'Creation_date': '21/10/2019', 'Creation_time': '16', 'File_name': 'TOP_DINANTIAN_TVD_final'}
- gemgis.raster.reproject_raster(path_in: str, path_out: str, dst_crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS], overwrite_file: bool = False, create_directory: bool = False)#
Reprojecting a raster into different CRS
- Parameters
path_in (str) – Path to the source file, e.g.
path_in='Images/'
path_out (str) – Path for the destination file, e.g.
path_out='Images/'
dst_crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – CRS of the destination file, e.g.
dst_crs='EPSG:25832'
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
New in version 1.0.x.
Changed in version 1.1: Fixing an issue where the file would be closed too soon, see https://github.com/cgre-aachen/gemgis/issues/294
Example
>>> # Loading Libraries >>> import gemgis as gg
>>> # Reprojecting raster >>> gg.raster.reproject_raster(path_in='raster_in.tif', path_out='raster_out.tif', dst_crs='EPSG:4326')
- gemgis.raster.resize_by_array(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], array: Union[numpy.ndarray, rasterio.io.DatasetReader]) numpy.ndarray #
Rescaling raster to the size of another raster
- Parameters
raster (Union[np.ndarray, rasterio.io.DatasetReader]) – Raster that is being resized
array (Union[np.ndarray, rasterio.io.DatasetReader]) – Raster with a size that the raster is being resized to
- Returns
array_resized – Resized array
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> import numpy as np >>> raster = rasterio.open(fp='raster.tif') >>> raster.read(1).shape (275, 250)
>>> # Creating array >>> array = np.zeros(100).reshape((10,10)) >>> array.shape (10, 10)
>>> # Resizing a raster by an array >>> raster_resized = gg.raster.resize_by_array(raster=raster, array=array) >>> raster_resized.shape (10, 10)
See also
resize_raster
Resizing a raster
- gemgis.raster.resize_raster(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], width: int, height: int) numpy.ndarray #
Resizing raster to given dimensions
- Parameters
array (Union[np.ndarray, rasterio.io.DatasetReader]) – Array that will be resized
width (int) – Width of the resized array, e.g.
width=100
height (int) – Height of the resized array, e.g.
height=100
- Returns
array_resized – Resized array
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> import numpy as np >>> raster = rasterio.open(fp='raster.tif') >>> raster.read(1).shape (275, 250)
>>> # Resizing raster >>> raster_resized = gg.raster.resize_raster(raster=raster, width=10, height=10) >>> raster_resized.shape (10, 10)
See also
resize_by_array
Resizing a raster by the shape of another array
- gemgis.raster.sample_from_array(array: numpy.ndarray, extent: Sequence[float], point_x: Union[float, int, list, numpy.ndarray], point_y: Union[float, int, list, numpy.ndarray]) Union[numpy.ndarray, float] #
Sampling the value of a np.ndarray at a given point and given the arrays true extent
- Parameters
array (np.ndarray) – Array containing the raster values
extent (list) – List containing the values for the extent of the array (minx,maxx,miny,maxy), e.g.
extent=[0, 972, 0, 1069]
point_x (Union[float, int, list, np.ndarray]) – Object containing the x coordinates of a point or points at which the array value is obtained, e.g.
point_x=100
point_y (Union[float, int, list, np.ndarray]) – Object containing the y coordinates of a point or points at which the array value is obtained, e.g.
point_y=100
- Returns
sample – Value/s of the raster at the provided position/s
- Return type
Union[np.ndarray, float]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Getting array data >>> array = raster.read()
>>> # Sampling values from an array >>> value = gg.raster.sample_from_array(array=array, extent=[0, 972, 0, 1069], point_x=500, point_y=500) >>> value 562.0227
See also
sample_from_rasterio
Sample values from rasterio object
sample_randomly
Sample randomly from rasterio object or NumPy array
sample_orientations
Sample orientations from raster
sample_interfaces
Sample interfaces from raster
- gemgis.raster.sample_from_rasterio(raster: rasterio.io.DatasetReader, point_x: Union[float, int, list, numpy.ndarray], point_y: Union[float, int, list, numpy.ndarray], sample_outside_extent: bool = True, sample_all_bands: bool = False) Union[list, float] #
Sampling the value of a rasterio object at a given point within the extent of the raster
- Parameters
raster (rasterio.io.DatasetReader) – Rasterio Object containing the height information
point_x (list, np.ndarray, float, int) – Object containing the x coordinates of a point or points at which the array value is obtained, e.g.
point_x=100
point_y (list, np.ndarray, float, int) – Object containing the y coordinates of a point or points at which the array value is obtained, e.g.
point_y=100
sample_outside_extent (bool) – Allow sampling outside the extent of the rasterio object. Options include:
True
orFalse
, default set toTrue
sample_all_bands (bool) – Allow sampling from all bands returning Options include:
True
orFalse
, default set toFalse
- Returns
sample – Value/s of the raster at the provided position/s
- Return type
list, float
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Sampling values from a rasterio object >>> value = gg.raster.sample_from_rasterio(raster=raster, point_x=500, point_y=500) >>> value 561.646728515625
See also
sample_from_array
Sample values from NumPy array
sample_randomly
Sample randomly from rasterio object or NumPy array
sample_orientations
Sample orientations from raster
sample_interfaces
Sample interfaces from raster
- gemgis.raster.sample_interfaces(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, point_x: Union[float, int, list, numpy.ndarray] = None, point_y: Union[float, int, list, numpy.ndarray] = None, random_samples: int = None, formation: str = None, seed: int = None, sample_outside_extent: bool = False, crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None) geopandas.geodataframe.GeoDataFrame #
Sampling interfaces from a raster
- Parameters
raster (Union[np.ndarray, rasterio.io.DatasetReader) – Raster or arrays from which points are being sampled
extent (List[Union[int, float]]) – List containing the extent of the raster (minx, maxx, miny, maxy), e.g.
extent=[0, 972, 0, 1069]
point_x (Union[float, int, list, np.ndarray]) – Object containing the x coordinates of a point or points at which the array value is obtained, e.g.
point_x=100
, default isNone
point_y (Union[float, int, list, np.ndarray]) – Object containing the y coordinates of a point or points at which the array value is obtained, e.g.
point_y=100
, default isNone
random_samples (int) – Number of random samples to be drawn, e.g.
random_samples=10
, default isNone
formation (str) – Name of the formation the raster belongs to, e.g.
formation='Layer1'
, default isNone
seed (int) – Integer to set a seed for the drawing of random values, e.g.
seed=1
, default isNone
sample_outside_extent (bool) – Allow sampling outside the extent of the rasterio object. Options include:
True
orFalse
, default isFalse
crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – Coordinate reference system to be passed to the GeoDataFrame upon creation, e.g.
crs='EPSG:4647
- Returns
gdf – GeoDataFrame containing the sampled interfaces
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Sampling interfaces from an array or rasterio object >>> gdf = gg.raster.sample_interfaces(raster=raster, point_x=500, point_y=500) >>> gdf X Y Z geometry 0 500.00 500.00 561.65 POINT (500.000 500.000)
See also
sample_from_array
Sample values from NumPy array
sample_from_rasterio
Sample values from rasterio object
sample_randomly
Sample randomly from rasterio object or NumPy array
sample_orientations
Sample orientations from raster
- gemgis.raster.sample_orientations(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], extent: List[Union[int, float]] = None, point_x: Union[float, int, list, numpy.ndarray] = None, point_y: Union[float, int, list, numpy.ndarray] = None, random_samples: int = None, formation: str = None, seed: int = None, sample_outside_extent: bool = False, crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None) geopandas.geodataframe.GeoDataFrame #
Sampling orientations from a raster
- Parameters
raster (Union[np.ndarray, rasterio.io.DatasetReader) – Raster or arrays from which points are being sampled
extent (List[Union[int, float]]) – List containing the extent of the raster (minx, maxx, miny, maxy), e.g.
extent=[0, 972, 0, 1069]
point_x (Union[float, int, list, np.ndarray]) – Object containing the x coordinates of a point or points at which the array value is obtained, e.g.
point_x=100
, default isNone
point_y (Union[float, int, list, np.ndarray]) – Object containing the y coordinates of a point or points at which the array value is obtained, e.g.
point_y=100
, default isNone
random_samples (int) – Number of random samples to be drawn, e.g.
random_samples=10
, default isNone
formation (str) – Name of the formation the raster belongs to, e.g.
formation='Layer1'
, default isNone
seed (int) – Integer to set a seed for the drawing of random values, e.g.
seed=1
, default isNone
sample_outside_extent (bool) – Allow sampling outside the extent of the rasterio object. Options include:
True
orFalse
, default isFalse
crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – Coordinate reference system to be passed to the GeoDataFrame upon creation, e.g.
crs='EPSG:4647
- Returns
gdf – GeoDataFrame containing the sampled interfaces
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Sampling orientations from an array or rasterio object >>> gdf = gg.raster.sample_orientations(raster=raster, point_x=500, point_y=500) >>> gdf X Y Z geometry dip azimuth polarity 0 500.00 500.00 561.65 POINT (500.000 500.000) 19.26 145.55 1
See also
sample_from_array
Sample values from NumPy array
sample_from_rasterio
Sample values from rasterio object
sample_randomly
Sample randomly from rasterio object or NumPy array
sample_interfaces
Sample interfaces from raster
- gemgis.raster.sample_randomly(raster: Union[numpy.ndarray, rasterio.io.DatasetReader], n: int = 1, extent: Optional[Sequence[float]] = None, seed: int = None) tuple #
Sampling randomly from a raster (array or rasterio object) using sample_from_array or sample_from_rasterio and a randomly drawn point within the array/raster extent
- Parameters
raster (Union[np.ndarray, rasterio.io.DatasetReader]) – NumPy Array or rasterio object containing the raster values
n (int) – Number of samples to be drawn, e.g.
n=10
, default1
extent (Optional[Sequence[float]]) – List containing the values for the extent of the array (minx,maxx,miny,maxy), default is
None
, e.g.extent=[0, 972, 0, 1069]
seed (int) – Seed for the random variable for reproducibility, e.g.
seed=1
, default isNone
- Returns
sample – Float of sampled raster value and list containing the x- and y-points of the point where sample was drawn
- Return type
tuple
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Sampling randomly from an array or rasterio object >>> value = gg.raster.sample_randomly(raster=raster, n=1) >>> value (617.0579833984375, [529.5110732824818, 717.7358438674542])
See also
sample_from_array
Sample values from NumPy array
sample_from_rasterio
Sample values from rasterio object
sample_orientations
Sample orientations from raster
sample_interfaces
Sample interfaces from raster
- gemgis.raster.save_as_tiff(raster: numpy.ndarray, path: str, extent: Union[List[Union[int, float]], Tuple[Union[int, float]]], crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS], nodata: Union[float, int] = None, transform=None, overwrite_file: bool = False, create_directory: bool = False)#
Saving a np.array as tif file
- Parameters
array (np.ndarray) – Array containing the raster values
path (string) – Path and name of the file, e.g.
path='mesh.msh'
extent (Union[List[Union[int, float]], Tuple[Union[int, float]]]) – List containing the bounds of the raster, e.g.
extent=[0, 972, 0, 1069]
crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – CRS of the saved raster, e.g.
crs='EPSG:4647'
nodata (Union[float, int]) – Nodata value of the raster, e.g.
nodata=9999.0
, defaultNone
transform – Transform of the data, default is
None
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default isFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Defining raster extent and CRS >>> extent = [0, 972, 0, 1069] >>> crs = 'EPSG:4326'
>>> # Saving raster as tiff >>> gg.raster.save_as_tiff(raster=raster.read(1), path='raster_saved.tif', extent=extent, crs=crs) Raster successfully saved
gemgis.utils module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.utils.assign_properties(lith_block: numpy.ndarray, property_dict: dict) numpy.ndarray #
Replacing lith block IDs with physical properties
- Parameters
lith_block (np.ndarray) – GemPy lith block array containing the surface IDs
property_array (dict) – Dict containing the property values mapped to a surface ID
- Returns
property_block – Array containing the properties
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and lith_block plus reshaping >>> import gemgis as gg >>> import numpy as np >>> lith_block = np.load('lith_block.npy').reshape(50,50,50)
>>> # Defining properties >>> density_values = [0.1, 2.5, 3.0]
>>> # Creating dict >>> density_dict = {k: v for k,v in zip(np.unique(np.round(lith_block)), density_values)} >>> density_dict {1.0: 0.1, 2.0: 2.5, 3.0: 3.0}
>>> # Assign properties >>> property_block = gg.utils.assign_properties(lith_block=lith_block, property_dict=property_dict)
- gemgis.utils.build_style_dict(classes: dict) dict #
Building a style dict based on extracted style classes
- Parameters
classes (dict) – Dict containing the styles of objects
- Returns
styles – Dict containing styles for different objects
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> column, classes = gg.utils.parse_categorized_qml(qml_name='style.qml') >>>column 'formation'
>>> # Inspecting classes >>> classes {'Sand1': {'border_width_map_unit_scale': '3x:0,0,0,0,0,0', 'color': '179,90,42,255', 'joinstyle': 'bevel', 'offset': '0,0', 'offset_map_unit_scale': '3x:0,0,0,0,0,0', 'offset_unit': 'MM', 'outline_color': '102,51,24,255', 'outline_style': 'solid', 'outline_width': '0.26', 'outline_width_unit': 'MM', 'style': 'solid'},....}
>>> # Creating Style Dict >>> style_dict = gg.utils.build_style_dict(classes=classes) >>> style_dict {'Sand1': {'color': '#b35a2a', 'color_rgb': [179, 90, 42], 'opacity': 1.0, 'weight': 0.26, 'fillColor': '#b35a2a', 'fillOpacity': 1.0},...}
See also
parse_categorized_qml
Reading the contents of a QGIS Style file (qml)
load_surface_colors
Loading surface colors as list
create_surface_color_dict
Creating dict with colors for each formation
- gemgis.utils.calculate_lines(gdf: Union[geopandas.geodataframe.GeoDataFrame, pandas.core.frame.DataFrame], increment: Union[float, int], xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z') geopandas.geodataframe.GeoDataFrame #
Function to interpolate strike lines
- Parameters
gdf (Union[gpd.geodataframe.GeoDataFrame, pd.DataFrame]) – (Geo-)DataFrame containing existing strike lines
increment (Union[float, int]) – Increment between the strike lines, e.g.
increment=50
xcol (str) – Name of X column, e.g.
x='X'
ycol (str) – Name of X column, e.g.
y='Y'
zcol (str) – Name of Z column, e.g.
z='Z'
- Returns
lines – GeoDataFrame with interpolated strike lines
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='lines5_strike.shp') >>> gdf id Z formation geometry 0 7 0 Coal1 LINESTRING (1642.839 2582.579, 2829.348 2205.937) 1 6 150 Coal1 LINESTRING (1705.332 1759.201, 2875.795 1406.768) 2 5 200 Coal1 LINESTRING (1017.766 1722.234, 2979.938 1137.003) 3 4 250 Coal1 LINESTRING (99.956 1763.424, 765.837 1620.705,... 4 3 200 Coal1 LINESTRING (1078.147 1313.501, 2963.048 752.760)
>>> gdf_interpolated = gg.utils.calculate_lines(gdf=gdf, increment=50)
- gemgis.utils.calculate_number_of_isopoints(gdf: Union[geopandas.geodataframe.GeoDataFrame, pandas.core.frame.DataFrame], increment: Union[float, int], zcol: str = 'Z') int #
Creating the number of isopoints to further interpolate strike lines
- Parameters
gdf (Union[gpd.geodataframe.GeoDataFrame, pd.DataFrame]) – (Geo-)DataFrame containing existing strike lines
increment (Union[float, int]) – Increment between the strike lines, e.g.
increment=50
zcol (string) – Name of z column, e.g.
z='Z'
, default is'Z'
- Returns
number – Number of isopoints
- Return type
int
New in version 1.0.x.
Example
>>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='lines5_strike.shp') >>> gdf id Z formation geometry 0 7 0 Coal1 LINESTRING (1642.839 2582.579, 2829.348 2205.937) 1 6 150 Coal1 LINESTRING (1705.332 1759.201, 2875.795 1406.768) 2 5 200 Coal1 LINESTRING (1017.766 1722.234, 2979.938 1137.003) 3 4 250 Coal1 LINESTRING (99.956 1763.424, 765.837 1620.705,... 4 3 200 Coal1 LINESTRING (1078.147 1313.501, 2963.048 752.760)
>>> number = gg.utils.calculate_number_of_isopoints(gdf=gdf, increment=50) >>> number 2
See also
get_nearest_neighbor
Getting the nearest neighbor to a point
- gemgis.utils.convert_crs_seismic_data(path_in: str, path_out: str, crs_in: Union[str, pyproj.crs.crs.CRS], crs_out: Union[str, pyproj.crs.crs.CRS], cdpx: int = 181, cdpy: int = 185, vert_domain: str = 'TWT', coord_scalar: int = None)#
Convert CDP coordinates of seismic data to a new CRS.
- Parameters
path_in (str) – Path to the original seismic data, e.g.
path_in='seismic.sgy'
.path_out (str) – Path to the converted seismic data, e.g.
path_out='seismic_converted.sgy'
.crs_in (str, pyproj.crs.crs.CRS) – Coordinate reference system of the original seismic data.
crs_out (str, pyproj.crs.crs.CRS) – Coordinate reference system of the converted seismic data.
cdpx (int) – Byte position for the X coordinates, default is
cdpx=181
.cdpy (int) – Byte position for the Y coordinates, default is
cdpx=185
.vert_domain (str) – Vertical sampling domain. Options include
'TWT'
and'DEPTH'
, default isvert_domain='TWT'
.coord_scalar (int) – Coordinate scalar value to set if NaN columns are returned, default is coord_scalar=None.
New in version 1.1.1.
- gemgis.utils.convert_location_dict_to_gdf(location_dict: dict) geopandas.geodataframe.GeoDataFrame #
Converting a location dict to a GeoDataFrame
- Parameters
location_dict (dict) – Dict containing the name of the location and the coordinates
- Returns
gdf – GeoDataFrame containing the location name and the coordinates of the location
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg
>>> # Creating a dict with coordinates >>> coordinates_dict = gg.utils.get_locations(names = ['Aachen', 'Berlin', 'München', 'Hamburg', 'Köln'], crs='EPSG:4647')
>>> # Converting dict to GeoDataFrame >>> gdf = gg.utils.convert_location_dict_to_gdf(location_dict=coordinates_dict) >>> gdf City X Y geometry 0 Aachen 32294411.33 5629009.36 POINT (32294411.335 5629009.357) 1 Berlin 32797738.56 5827603.74 POINT (32797738.561 5827603.740) 2 München 32691595.36 5334747.27 POINT (32691595.356 5334747.274) 3 Hamburg 32566296.25 5933959.96 POINT (32566296.251 5933959.965) 4 Köln 32356668.82 5644952.10 POINT (32356668.818 5644952.100)
- gemgis.utils.convert_to_gempy_df(gdf: geopandas.geodataframe.GeoDataFrame, dem: Union[rasterio.io.DatasetReader, numpy.ndarray] = None, extent: List[Union[int, float]] = None) pandas.core.frame.DataFrame #
Converting a GeoDataFrame into a Pandas DataFrame ready to be read in for GemPy
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing spatial information, formation names and orientation values
dem (Union[np.ndarray, rasterio.io.DatasetReader]) – NumPy ndarray or rasterio object containing the height values
extent (List[Union[float,int]) – List containing the extent of the np.ndarray, must be provided in the same CRS as the gdf, e.g.
extent=[0, 972, 0, 1069]
- Returns
df – Interface or orientations DataFrame ready to be read in for GemPy
- Return type
pd.DataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> import rasterio >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Loading Digital Elevation Model >>> dem = rasterio.open(fp='dem.tif') >>> dem <open DatasetReader name='dem.tif' mode='r'>
>>> # Defining extent >>> extent = [0, 972, 0, 1069]
>>> # Converting GeoDataFrame to DataFrame >>> df = gg.utils.convert_to_gempy_df(gdf=gdf, dem=dem, extent=extent) >>> df formation X Y Z 0 Ton 19.15 293.31 364.99 1 Ton 61.93 381.46 400.34 2 Ton 109.36 480.95 459.55 3 Ton 157.81 616.00 525.69 4 Ton 191.32 719.09 597.63
- gemgis.utils.convert_to_petrel_points_with_attributes(mesh: pyvista.core.pointset.PolyData, path: str, crs: Optional[Union[str, pyproj.crs.crs.CRS]] = None, target_crs: Optional[Union[str, pyproj.crs.crs.CRS]] = None)#
Function to convert vertices of a PyVista Mesh to Petrel Points with Attributes
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista Mesh to be converted to points
path (str) – Path to store the converted points, e.g.
path='project/'
crs (str, pyproj.crs.crs.CRS, type(None)) – Coordinate reference system for the GeoDataFrame, e.g.
crs='EPSG:4326'
, default isNone
target_crs (str, pyproj.crs.crs.CRS, type(None)) – Target coordinate reference system if coordinates of points should be reprojected, e.g.
crs='EPSG:4326'
, default isNone
New in version 1.0.x.
- gemgis.utils.create_polygon_from_location(coordinates) shapely.geometry.polygon.Polygon #
Creating Shapely Polygon from bounding box coordinates
- Parameters
coordinates (geopy.location.Location) – GeoPy location object
- Returns
polygon – Shapely Polygon marking the bounding box of the coordinate object
- Return type
shapely.geometry.polygon.Polygon
New in version 1.0.x.
Example
>>> # Loading Libraries and get location object >>> import gemgis as gg >>> location = gg.utils.get_location_coordinate(name='Aachen') >>> location Location(Aachen, Städteregion Aachen, Nordrhein-Westfalen, Deutschland, (50.776351, 6.083862, 0.0))
>>> # Creating polygon from location bounds >>> polygon = gg.utils.create_polygon_from_location(coordinates=location) >>> polygon.wkt 'POLYGON ((50.8572449 5.9748624, 50.8572449 6.2180747, 50.6621373 6.2180747, 50.6621373 5.9748624, 50.8572449 5.9748624))'
See also
transform_location_coordinate
Transforming location coordinate to another CRS
get_location_coordinate
Get GeoPy Location Object
get_locations
Get location information for a list of city names
- gemgis.utils.create_surface_color_dict(path: str) dict #
Creating GemPy surface color dict from a QML file
- Parameters
path (str) – Path to the qml file, e.g.
qml_name='style.qml'
- Returns
surface_color_dict – Dict containing the surface color values for GemPy
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> surface_colors_dict = gg.utils.create_surface_color_dict(path='style.qml') >>> surface_colors_dict {'Sand1': '#b35a2a', 'Sand2': '#b35a2a', 'Ton': '#525252'}
See also
build_style_dict
Building style dictionairy from loaded style file
parse_categorized_qml
Reading the contents of a QGIS Style file (qml)
load_surface_colors
Loading surface colors as list
- gemgis.utils.create_virtual_profile(names_surfaces: list, surfaces: list, borehole: pyvista.core.pointset.PolyData, first_point: bool = False) pandas.core.frame.DataFrame #
Function to filter and sort the resulting well tops
- Parameters
names_surfaces (list) – List of the names of the calculated GemPy surfaces, e.g.
names_surfaces=['Layer1', 'Layer2']
surfaces (list) – List of calculated GemPy surfaces, e.g.
surfaces=['Layer1', 'Layer2']
borehole (pv.core.pointset.PolyData) – Coordinates of the bottom of the well
first_point (bool) – Returns intersection of first point only. Options include:
True
orFalse
, default set toFalse
- Returns
df – DataFrame containing the well tops
- Return type
pd.DataFrame
New in version 1.0.x.
- gemgis.utils.create_zmap_grid(surface: pyvista.core.pointset.PolyData, cell_width: int, comments: str = '', name: str = 'ZMAP_Grid', z_type: str = 'GRID', nodes_per_line: int = 5, field_width: int = 15, nodata: Union[int, float] = - 9999.0, nodata2: Union[int, float, str] = '', decimal_places: int = 5, start_column: int = 1)#
Function to write data to ZMAP Grid, This code is heavily inspired by https://github.com/abduhbm/zmapio
- Parameters
surface (pv.core.pointset.PolyData) – PyVista mesh
cell_width (int) – Width of grid cell, e.g.
cell_width=50
comments (str) – Comments written to the ZMAP File, e.g.
comments='Project: Einstein'
, default is''
name (str) – Name of the ZMAP File, e.g.
name='ZMAP_Grid'
, default is'ZMAP_Grid'
z_type (str) – ZMAP Grid Type, e.g.
z_type='GRID'
, default is'GRID'
nodes_per_lines (int) – Number of values per line, e.g.
nodes_per_line=5
, default is5
field_width (int) – Width of each field, e.g.
field_width=15
, default is15
nodata (Union[int, float]) – No data value, e.g.
nodata=-9999
, default is-9999
nodata2 (Union[int, float, str]) – No data value, e.g.
nodata2=-9999
, default is''
decimal_places (int) – Number of Decimal Places, e.g.
decimal_places=5
, default is5
start_column (int) – Number of the start column, e.g.
start_column=1
, default is1
- Returns
lines – String containing the ZMAP Grid Data
- Return type
str
New in version 1.0.x.
- gemgis.utils.extract_zmap_data(surface: pyvista.core.pointset.PolyData, cell_width: int, nodata: Union[float, int] = - 9999)#
Function to extract a meshgrid of values from a PyVista mesh
- Parameters
surface (pv.core.pointset.PolyData) – PyVista mesh
cell_width (int) – Width of grid cell, e.g.
cell_width=50
nodata (Union[float, int]) – No data value, e.g.
nodata=-9999
, default is-9999
New in version 1.0.x.
- gemgis.utils.get_cdp_linestring_of_seismic_data(path_in: str, crs_in: Union[str, pyproj.crs.crs.CRS], cdpx: int = 181, cdpy: int = 185, vert_domain: str = 'TWT')#
Extracting the path of the seismic data as LineString.
- Parameters
path_in (str) – Path to the original seismic data, e.g.
path_in='seismic.sgy'
.crs_in (str, pyproj.crs.crs.CRS) – Coordinate reference system of the original seismic data.
cdpx (int) – Byte position for the X coordinates, default is
cdpx=181
.cdpy (int) – Byte position for the Y coordinates, default is
cdpx=185
.vert_domain (str) – Vertical sampling domain. Options include
'TWT'
and'DEPTH'
, default isvert_domain='TWT'
.
- Returns
GeoDataFrame containing the surface path of the seismic data as LineString.
- Return type
gpd.GeoDataFrame
New in version 1.1.1.
- gemgis.utils.get_cdp_points_of_seismic_data(path_in: str, crs_in: Union[str, pyproj.crs.crs.CRS], cdpx: int = 181, cdpy: int = 185, vert_domain: str = 'TWT', filter: int = None, n_meter: Union[int, float] = None)#
Extracting the path of the seismic data as LineString.
- Parameters
path_in (str) – Path to the original seismic data, e.g.
path_in='seismic.sgy'
.crs_in (str, pyproj.crs.crs.CRS) – Coordinate reference system of the original seismic data.
cdpx (int) – Byte position for the X coordinates, default is
cdpx=181
.cdpy (int) – Byte position for the Y coordinates, default is
cdpx=185
.vert_domain (str) – Vertical sampling domain. Options include
'TWT'
and'DEPTH'
, default isvert_domain='TWT'
.filter (int) – Filtering the points to only return every n-th point, e.g.
filter=100
to return only every 100-th point.n_meter (int, float) – Parameter to select a point along the line every n-th meter.
- Returns
GeoDataFrame containing the CDPs as Points.
- Return type
gpd.GeoDataFrame
New in version 1.1.1.
- gemgis.utils.get_location_coordinate(name: str)#
Obtaining coordinates of a given city
- Parameters
name (str) – Name of the location, e.g.
name='Aachen'
- Returns
coordinates – GeoPy Location object
- Return type
geopy.location.Location
New in version 1.0.x.
Example
>>> # Loading Libraries and get location object >>> import gemgis as gg >>> location = gg.utils.get_location_coordinate(name='Aachen') >>> location Location(Aachen, Städteregion Aachen, Nordrhein-Westfalen, Deutschland, (50.776351, 6.083862, 0.0))
See also
transform_location_coordinate
Transforming location coordinate to another CRS
create_polygon_from_location
Create Shapely Polygon from GeoPy Location Object bounds
get_locations
Get location information for a list of city names
- gemgis.utils.get_locations(names: Union[list, str], crs: Union[str, pyproj.crs.crs.CRS] = 'EPSG:4326') dict #
Obtaining coordinates for one city or a list of given cities. A CRS other than ‘EPSG:4326’ can be passed to transform the coordinates
- Parameters
names (Union[list, str]) – List of cities or single city name, e.g.
names=['Aachen', 'Cologne', 'Munich', 'Berlin']
crs (Union[str, pyproj.crs.crs.CRS]) – CRS that coordinates will be transformed to, e.g.
crs='EPSG:4647'
, default is the GeoPy crs'EPSG:4326'
- Returns
location_dict – Dict containing the addresses and coordinates of the selected cities
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and get location objects >>> import gemgis as gg >>> names = ['Aachen', 'Cologne', 'Munich', 'Berlin'] >>> location_dict = gg.utils.get_locations(names=names, crs='EPSG:4647') >>> location_dict {'Aachen, Städteregion Aachen, Nordrhein-Westfalen, Deutschland': (32294411.33488576, 5629009.357074926), 'Köln, Nordrhein-Westfalen, Deutschland': (32356668.818424627, 5644952.099932303), 'München, Bayern, Deutschland': (32691595.356409974, 5334747.274305081), 'Berlin, 10117, Deutschland': (32797738.56053437, 5827603.740024588)}
See also
transform_location_coordinate
Transforming location coordinate to another CRS
get_location_coordinate
Get GeoPy Location Object
create_polygon_from_location
Create Shapely Polygon from GeoPy Location Object bounds
- gemgis.utils.get_nearest_neighbor(x: numpy.ndarray, y: numpy.ndarray) numpy.int64 #
Function to return the index of the nearest neighbor for a given point Y
- Parameters
x (np.ndarray) – Array with coordinates of a set of points, e.g.
x=np.array([(0,0), (10,10)])
y (np.ndarray) – Array with coordinates for point y, e.g.
y=np.array([2,2])
- Returns
index – Index of the nearest neighbor of point set X to point Y
- Return type
np.int64
New in version 1.0.x.
Example
>>> import gemgis as gg >>> import numpy as np >>> x = np.array([(0,0), (10,10)]) >>> x array([[ 0, 0], [10, 10]])
>>> y = np.array([2,2]) >>> y array([2, 2])
>>> index = gg.utils.get_nearest_neighbor(x=x, y=y) >>> index 0
See also
calculate_number_of_isopoints
Calculating the number of isopoints that are necessary to interpolate lines
- gemgis.utils.getfeatures(extent: Optional[List[Union[int, float]]], crs_raster: Union[str, dict], crs_bbox: Union[str, dict], bbox: shapely.geometry.polygon.Polygon = None) list #
Creating a list containing a dict with keys and values to clip a raster
- Parameters
extent (Union[List[Union[int, float]]) – List of bounds (minx,maxx, miny, maxy), e.g.
extent=[0, 972, 0, 1069]
crs_raster (Union[str, dict]) – String or dict containing the raster crs, e.g.
crs='EPSG:4647'
crs_bbox (Union[str, dict]) – String or dict containing the bbox crs, e.g.
crs='EPSG:4647'
bbox (shapely.geometry.polygon.Polygon) – Shapely polygon defining the bbox used to get the coordinates, , e.g.
polygon = Polygon([(0, 0), (0, 10), (10, 10), (10, 0)])
- Returns
data – List containing a dict with keys and values to clip raster
- Return type
list
New in version 1.0.x.
- gemgis.utils.interpolate_strike_lines(gdf: geopandas.geodataframe.GeoDataFrame, increment: Union[float, int], xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z') geopandas.geodataframe.GeoDataFrame #
Interpolating strike lines to calculate orientations
- Parameters
gdf (Union[gpd.geodataframe.GeoDataFrame, pd.DataFrame]) – (Geo-)DataFrame containing existing strike lines
increment (Union[float, int]) – Increment between the strike lines, e.g.
increment=50
xcol (str) – Name of X column, e.g.
x='X'
ycol (str) – Name of X column, e.g.
y='Y'
zcol (str) – Name of Z column, e.g.
z='Z'
- Returns
gdf_out – GeoDataFrame containing the existing and interpolated strike lines
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
- gemgis.utils.load_surface_colors(path: str, gdf: geopandas.geodataframe.GeoDataFrame) List[str] #
Loading surface colors from a QML file and storing the color values as list to be displayed with GeoPandas plots
- Parameters
path (str) – Path to the qml file, e.g.
qml_name='style.qml'
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame of which objects are supposed to be plotted, usually loaded from a polygon/line shape file
- Returns
cols – List of color values for each surface
- Return type
List[str]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp')
>>> # Loading surface colors >>> colors = gg.utils.load_surface_colors(path='style.qml', gdf=gdf) >>> colors ['#b35a2a', '#b35a2a', '#525252']
See also
build_style_dict
Building style dictionairy from loaded style file
parse_categorized_qml
Reading the contents of a QGIS Style file (qml)
create_surface_color_dict
Creating dict with colors for each formation
- gemgis.utils.open_mpk(path_in: str)#
Read ArcGIS .mpk file and return vector and raster data.
- Parameters
path_in (str) – Path to the .mpk file, e.g.
path='file.mpk'
- Returns
dict_vector_data (dict) – Dictionary containing the extracted vector data.
dict_raster_data (dict) – Dictionary containing the extracted raster data.
Example
- gemgis.utils.parse_categorized_qml(qml_name: str) tuple #
Parsing a QGIS style file to retrieve surface color values
- Parameters
qml_name (str) – Path to the QML file, e.g.
qml_name='style.qml'
- Returns
column (str) – Variable indicating after which formation the objects were colored (i.e.
'formation'
)classes (dict) – Dict containing the style attributes for all available objects
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> column, classes = gg.utils.parse_categorized_qml(qml_name='style.qml') >>> column 'formation'
>>> # Inspecting classes >>> classes {'Sand1': {'border_width_map_unit_scale': '3x:0,0,0,0,0,0', 'color': '179,90,42,255', 'joinstyle': 'bevel', 'offset': '0,0', 'offset_map_unit_scale': '3x:0,0,0,0,0,0', 'offset_unit': 'MM', 'outline_color': '102,51,24,255', 'outline_style': 'solid', 'outline_width': '0.26', 'outline_width_unit': 'MM', 'style': 'solid'},....}
See also
build_style_dict
Building style dictionairy from loaded style file
load_surface_colors
Loading surface colors as list
create_surface_color_dict
Creating dict with colors for each formation
- gemgis.utils.ray_trace_multiple_surfaces(surfaces: list, borehole_top: Union[numpy.ndarray, list], borehole_bottom: Union[numpy.ndarray, list], first_point: bool = False) list #
Function to return the depth of multiple surfaces in one well using PyVista ray tracing
- Parameters
surfaces (list) – List of calculated GemPy surfaces
borehole_top – Coordinates of the top of the well
borehole_bottom – Coordinates of the bottom of the well
first_point (bool) – Returns intersection of first point only
- Returns
intersections – List of intersections
- Return type
list
New in version 1.0.x.
- gemgis.utils.ray_trace_one_surface(surface: Union[pyvista.core.pointset.PolyData, pyvista.core.pointset.UnstructuredGrid], origin: Union[numpy.ndarray, list], end_point: Union[numpy.ndarray, list], first_point: bool = False) tuple #
Function to return the depth of one surface in one well using PyVista ray tracing
- Parameters
surface (Union[pv.core.pointset.PolyData, pv.core.pointset.UnstructuredGrid]) – Calculated or clipped GemPy surface
origin – Coordinates of the top of the well
end_point – Coordinates of the bottom of the well
first_point (bool) – Returns intersection of first point only
- Returns
intersection_points, intersection_cells – Location of the intersection points, Indices of the intersection cells
- Return type
tuple
New in version 1.0.x.
- gemgis.utils.read_csv_as_gdf(path: str, crs: Union[str, pyproj.crs.crs.CRS], x: str = 'X', y: str = 'Y', z: str = None, delimiter: str = ',') geopandas.geodataframe.GeoDataFrame #
Reading CSV files as GeoDataFrame
- Parameters
path (str) – Path of the CSV files, e.g.
path='file.csv'
crs (Union[str, pyproj.crs.crs.CRS]) – CRS of the spatial data, e.g.
crs='EPSG:4647'
x (str) – Name of the X column, e.g.
x='X'
, default is'X'
y (str) – Name of the Y column, e.g.
y='Y'
, default is'Y'
z (str) – Name of the Z column, e.g.
z='Z'
, default is'Z'
delimiter (str) – Delimiter of CSV file, e.g.
delimiter=','
, default is ‘,’
- Returns
gdf – GeoDataFrame of the CSV data
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File as GeoDataFrame >>> import gemgis as gg >>> gdf = gg.utils.read_csv_as_gdf(path='file.csv') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
- gemgis.utils.rotate_gempy_input_data(extent: Union[numpy.ndarray, shapely.geometry.polygon.Polygon, geopandas.geodataframe.GeoDataFrame], interfaces: Union[pandas.core.frame.DataFrame, geopandas.geodataframe.GeoDataFrame], orientations: Union[pandas.core.frame.DataFrame, geopandas.geodataframe.GeoDataFrame], zmin: Union[float, int] = None, zmax: Union[float, int] = None, rotate_reverse_direction: bool = False, return_extent_gdf: bool = False, manual_rotation_angle: Union[float, int] = None)#
Function to rotate the GemPy Input Data horizontally or vertically
- Parameters
extent (np.ndarray, shapely.geometry.Polygon, gpd.geodataframe.GeoDataFrame) – Extent of the Model
interfaces (pd.DataFrame, gpd.geodataframe.GeoDataFrame) – Interface points for the GemPy Model
orientations (pd.DataFrame, gpd.geodataframe.GeoDataFrame) – Orientations for the GemPy Model
zmin (float, int) – Lower Z limit of the GemPy Model, e.g.
zmin=-1000
, default isNone
zmax (float, int) – Upper Z limit of the GemPy Model, e.g.
zmax=1000
, default isNone
rotate_reverse_direction (bool) – Rotating the model the other direction. Options include:
True
orFalse
, default set toFalse
return_extent_gdf (bool) – Returning the extent GeoDataFrame. Options include:
True
orFalse
, default set toFalse
manual_rotation_angle (float, int) – Angle to manually rotate the data, e.g.
manual_rotation_angle=45
, default isNone
- Returns
extent (list) – New GemPy Model extent, e.g.
extent=[0, 972, 0, 1069]
interfaces_rotated (pd.DataFrame, gpd.geodataframe.GeoDataFrame) – Rotated interfaces for the structural modeling in GemPy
orientations_rotated (pd.DataFrame, gpd.geodataframe.GeoDataFrame) – Rotated orientations for the structural modeling in GemPy
New in version 1.1.
- gemgis.utils.save_zmap_grid(zmap_grid: list, path: str = 'ZMAP_Grid.dat')#
Function to save ZMAP Grid information to file
- Parameters
zmap_grid (list) – List of strings containing the ZMAP Data
path (str) – Path and filename to store the ZMAP Grid, e.g.
path='ZMAP_Grid.dat'
, default is'ZMAP_Grid.dat'
New in version 1.0.x.
- gemgis.utils.set_extent(minx: Union[int, float] = 0, maxx: Union[int, float] = 0, miny: Union[int, float] = 0, maxy: Union[int, float] = 0, minz: Union[int, float] = 0, maxz: Union[int, float] = 0, gdf: geopandas.geodataframe.GeoDataFrame = None) List[Union[int, float]] #
Setting the extent for a model
- Parameters
minx (Union[int, float]) – Value defining the left border of the model, e.g.
minx=0
, default is0
maxx (Union[int, float]) – Value defining the right border of the model, e.g.
max=972
, default is0
miny (Union[int, float]) – Value defining the upper border of the model, e.g.
miny=0
, default is0
maxy (Union[int, float]) – Value defining the lower border of the model, e.g.
maxy=1069
, default is0
minz (Union[int, float]) – Value defining the top border of the model, e.g.
minz=0
, default is0
maxz (Union[int, float]) – Value defining the bottom border of the model, e.g.
maxz=1000
, default is0
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame from which bounds the extent will be set, default is
None
- Returns
extent – List containing extent values
- Return type
List[Union[int, float]]
New in version 1.0.x.
Example
>>> # Loading Libraries and setting the extent >>> import gemgis as gg >>> extent = gg.utils.set_extent(minx=0, maxx=972, miny=0, maxy=1069, minz=0, maxz=1000) >>> extent [0, 972, 0, 1069, 0, 1000]
- gemgis.utils.set_resolution(x: int, y: int, z: int) List[int] #
Setting the resolution for a model
- Parameters
x (int) – Value defining the resolution in X direction, e.g.
x=50
y (int) – Value defining the resolution in Y direction, e.g.
y=50
z (int) – Value defining the resolution in Z direction, e.g.
z=50
- Returns
resolution – List containing resolution values
- Return type
List[int]
New in version 1.0.x.
Example
>>> # Loading Libraries and setting the resolution >>> import gemgis as gg >>> res = gg.utils.set_resolution(x=50, y=50, z=50) >>> res [50, 50, 50]
- gemgis.utils.show_number_of_data_points(geo_model)#
Adding the number of Interfaces and Orientations to the GemPy Surface dataframe
- Parameters
geo_model (gp.core.model.Project) – GemPy geo_model object
- Returns
geo_model.surfaces – DataFrame-like object containing surface information and number of data points
- Return type
gempy.core.model.RestrictingWrapper
New in version 1.0.x.
Example
>>> # Loading Libraries and displaying surface DataFrame of a GemPy geo_model >>> import gemgis as gg >>> geo_model.surfaces surface series order_surfaces color id 0 Sand1 Strat_Series 1 #015482 1 1 Ton Strat_Series 2 #9f0052 2 2 basement Strat_Series 3 #ffbe00 3
>>> # Adding number of data points to DataFrame >>> gg.utils.show_number_of_data_points(geo_model=geo_model) surface series order_surfaces color id No. of Interfaces No. of Orientations 0 Sand1 Strat_Series 1 #015482 1 95 0 1 Ton Strat_Series 2 #9f0052 2 36 8 2 basement Strat_Series 3 #ffbe00 3 0 0
- gemgis.utils.to_section_dict(gdf: geopandas.geodataframe.GeoDataFrame, section_column: str = 'section_name', resolution: List[int] = None) dict #
Converting custom sections stored in Shape files to GemPy section_dicts
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the points or lines of custom sections
section_column (str) – String containing the name of the column containing the section names, e.g.
section_column='section_name'
, default is'section_name'
List[int] (resolution -) – List containing the x,y resolution of the custom section, e.g.
resolution=[80,80]
- Returns
section_dict – Dict containing the section names, coordinates and resolution
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id geometry Section 0 None POINT (695.467 3.226) Section1 1 None POINT (669.284 1060.822) Section1
>>> # Creating Section dict >>> section_dict = gg.utils.to_section_dict(gdf=gdf, section_column='Section') >>> section_dict {'Section1': ([695.4667461080886, 3.2262250771374283], [669.2840030245482, 1060.822026058724], [100, 80])}
- gemgis.utils.transform_location_coordinate(coordinates, crs: Union[str, pyproj.crs.crs.CRS]) dict #
Transforming coordinates of GeoPy Location
- Parameters
coordinates (geopy.location.Location) – GeoPy location object
crs (Union[str, pyproj.crs.crs.CRS]) – Name of the target crs, e.g.
crs='EPSG:4647'
- Returns
result_dict – Dict containing the location address and transformed coordinates
- Return type
dict
New in version 1.0.x.
Changed in version 1.1.7.
Updated to use the latest pyproj transformer
Example
>>> # Loading Libraries and get location object >>> import gemgis as gg >>> location = gg.utils.get_location_coordinate(name='Aachen') >>> location Location(Aachen, Städteregion Aachen, Nordrhein-Westfalen, Deutschland, (50.776351, 6.083862, 0.0))
>>> # Transforming location coordinates >>> result_dict = gg.utils.transform_location_coordinate(coordinates=location, crs='EPSG:4647') >>> result_dict {'Aachen, Städteregion Aachen, Nordrhein-Westfalen, Deutschland': (32294411.33488576, 5629009.357074926)}
See also
get_location_coordinate
Get GeoPy Location Object
create_polygon_from_location
Create Shapely Polygon from GeoPy Location Object bounds
get_locations
Get location information for a list of city names
gemgis.vector module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.vector.calculate_angle(linestring: shapely.geometry.linestring.LineString) float #
Calculating the angle of a LineString to the vertical
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString consisting of two vertices, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
angle – Angle of a LineString to the vertical
- Return type
float
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 20)'
>>> # Calculating the strike angle of the LineString >>> angle = gg.vector.calculate_angle(linestring=linestring) >>> angle 135.0
See also
calculate_strike_direction_straight_linestring
Calculating the strike direction of a straight LineString
calculate_strike_direction_bent_linestring
Calculating the strike direction of a bent LineString
calculate_dipping_angle_linestring
Calculate the dipping angle of a LineString
calculate_dipping_angles_linestrings
Calculate the dipping angles of LineStrings
Note
The LineString must only consist of two points (start and end point)
- gemgis.vector.calculate_azimuth(gdf: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) List[Union[int, float]] #
Calculating the azimuth for an orientation Geodataframe represented by LineStrings
- Parameters
gdf (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]) – GeoDataFrame or list containing the LineStrings of orientations
- Returns
azimuth_list – List containing the azimuth values of the orientation LineString
- Return type
List[Union[float, int]]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> import geopandas as gpd >>> linestring1 = LineString([(0, 0), (20, -20)]) >>> linestring1.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating second LineString >>> linestring2 = LineString([(0, 0), (20, -10)]) >>> linestring2.wkt 'LINESTRING (0 0, 20 -10)'
>>> # Creating GeoDataFrame from LineStrings >>> gdf = gpd.GeoDataFrame(geometry=[linestring1, linestring2]) >>> gdf geometry 0 LINESTRING (0.0 0.0, 20.0 -20.0) 1 LINESTRING (0.0 0.0, 20.0 -10.0)
>>> # Calculating the azimuths of the LineStrings >>> azimuths = gg.vector.calculate_azimuth(gdf=gdf) >>> azimuths [135.0, 116.56505117707799]
See also
create_linestring_from_points
Create LineString from points
create_linestring_gdf
Create GeoDataFrame with LineStrings from points
extract_orientations_from_map
Extracting orientations from a map
calculate_distance_linestrings
Calculating the distance between LineStrings
calculate_orientations_from_strike_lines
Calculating the orientations from strike lines
- gemgis.vector.calculate_coordinates_for_linestring_on_cross_sections(linestring: shapely.geometry.linestring.LineString, interfaces: shapely.geometry.linestring.LineString)#
Calculating the coordinates of vertices for a LineString on a straight cross section provided as Shapely LineString
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
linestring = LineString([(0, 0), (20, 20)])
interfaces (shapely.geometry.linestring.LineString) – Shapely LineString containing the interfaces points digitized on a cross section, e.g.
interfaces = LineString([(2, -2), (5, -5)])
- Returns
points – List of Shapely Points with real world coordinates of digitized points on cross section
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating second LineString >>> interfaces = LineString([(2, -2), (5, -5)]) >>> interfaces.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Calculating coordinates for LineString on cross section >>> points = gg.vector.calculate_coordinates_for_linestring_on_cross_sections(linestring=linestring, interfaces=interfaces) >>> points [<shapely.geometry.point.Point at 0x231e8dc4d60>, <shapely.geometry.point.Point at 0x231e5d9b070>]
>>> # Inspecting the first element of the list >>> points[0].wkt 'POINT (1.414213562373095 -1.414213562373095)'
>>> # Inspecting the second element of the list >>> points[1].wkt 'POINT (3.535533905932737 -3.535533905932737)'
See also
calculate_coordinates_for_point_on_cross_section
Calculating the coordinates for a Point on a cross section
calculate_coordinates_for_linestrings_on_cross_sections
Calculating the coordinates for LineStrings on cross sections
extract_interfaces_coordinates_from_cross_section
Extracting the coordinates of interfaces from cross sections
extract_xyz_from_cross_sections
Extracting the X, Y, and Z coordinates of interfaces from cross sections
- gemgis.vector.calculate_coordinates_for_linestrings_on_cross_sections(linestring: shapely.geometry.linestring.LineString, linestring_interfaces_list: List[shapely.geometry.linestring.LineString]) List[shapely.geometry.point.Point] #
Calculating the coordinates of vertices for LineStrings on a straight cross section provided as Shapely LineString
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
linestring_interfaces_list (List[shapely.geometry.linestring.LineString]) – List containing Shapely LineStrings representing interfaces on cross sections
- Returns
points – List containing Shapely Points with real world coordinates of the digitized interfaces on the cross section
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating second LineString >>> interfaces = LineString([(2, -2), (5, -5)]) >>> interfaces.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Creating list of LineStrings >>> linestring_interfaces_list = [interfaces, interfaces]
>>> # Calculating coordinates for LineStrings on cross section >>> points = gg.vector.calculate_coordinates_for_linestrings_on_cross_sections(linestring=linestring, linestring_interfaces_list=linestring_interfaces_list) >>> points [<shapely.geometry.point.Point at 0x231e8019730>, <shapely.geometry.point.Point at 0x231e801e400>, <shapely.geometry.point.Point at 0x231e80192e0>, <shapely.geometry.point.Point at 0x231e80191f0>]
>>> # Inspecting the first element of the list >>> points[0].wkt 'POINT (1.414213562373095 -1.414213562373095)'
>>> # Inspecting the second element of the list >>> points[1].wkt 'POINT (3.535533905932737 -3.535533905932737)'
>>> # Inspecting the third element of the list >>> points[2].wkt 'POINT (1.414213562373095 -1.414213562373095)'
>>> # Inspecting the fourth element of the list >>> points[3].wkt 'POINT (3.535533905932737 -3.535533905932737)'
See also
calculate_coordinates_for_point_on_cross_section
Calculating the coordinates for a Point on a cross section
calculate_coordinates_for_linestring_on_cross_sections
Calculating the coordinates for one LineString on cross sections
extract_interfaces_coordinates_from_cross_section
Extracting the coordinates of interfaces from cross sections
extract_xyz_from_cross_sections
Extracting the X, Y, and Z coordinates of interfaces from cross sections
- gemgis.vector.calculate_coordinates_for_point_on_cross_section(linestring: shapely.geometry.linestring.LineString, point: Union[shapely.geometry.point.Point, Tuple[float, float]])#
Calculating the coordinates for one point digitized on a cross section provided as Shapely LineString
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
linestring = LineString([(0, 0), (20, 20)])
point (Union[shapely.geometry.point.Point, Tuple[float, float]]) – Shapely object or tuple of X and Y coordinates digitized on a cross section e.g.
point = Point(5, 0)
- Returns
point – Shapely Point with real world X and Y coordinates extracted from cross section LineString on Map
- Return type
shapely.geometry.point.Point
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating Point >>> point = Point(5, 0) >>> point.wkt 'POINT (5 0)'
>>> # Calculating real world coordinates for point on cross section >>> point_xy = gg.vector.calculate_coordinates_for_point_on_cross_section(linestring=linestring, point=point) >>> point_xy.wkt 'POINT (3.535533905932737 -3.535533905932737)'
See also
calculate_coordinates_for_linestring_on_cross_sections
Calculating the coordinates for a LineString on a cross section
calculate_coordinates_for_linestrings_on_cross_sections
Calculating the coordinates for LineStrings on cross sections
extract_interfaces_coordinates_from_cross_section
Extracting the coordinates of interfaces from cross sections
extract_xyz_from_cross_sections
Extracting the X, Y, and Z coordinates of interfaces from cross sections
- gemgis.vector.calculate_dipping_angle_linestring(linestring: shapely.geometry.linestring.LineString)#
Calculating the dipping angle of a LineString digitized on a cross section
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString digitized on a cross section, e.g.
linestring = LineString([(0, 0), (20, 20)])
- Returns
dip – Dipping angle of the LineString
- Return type
float
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating dipping angle from LineString >>> angle = gg.vector.calculate_dipping_angle_linestring(linestring=linestring) >>> angle 45.0
See also
calculate_angle
Calculating the angle of a LineString
calculate_strike_direction_straight_linestring
Calculating the strike direction of a straight LineString
calculate_strike_direction_bent_linestring
Calculating the strike direction of a bent LineString
calculate_dipping_angles_linestrings
Calculate the dipping angles of LineStrings
Note
The LineString must only consist of two points (start and end point)
- gemgis.vector.calculate_dipping_angles_linestrings(linestring_list: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]])#
Calculating the dipping angles of LineStrings digitized on a cross section
- Parameters
linestring_list (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) – GeoDataFrame containing LineStrings or list of LineStrings
- Returns
dipping_angles – List containing the dipping angles of LineStrings
- Return type
List[float]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating list of LineStrings >>> linestring_list = [linestring, linestring]
>>> # Calculating dipping angles for LineStrings >>> angles = gg.vector.calculate_dipping_angles_linestrings(linestring_list=linestring_list) >>> angles [45.0, 45.0]
See also
calculate_angle
Calculating the angle of a LineString
calculate_strike_direction_straight_linestring
Calculating the strike direction of a straight LineString
calculate_strike_direction_bent_linestring
Calculating the strike direction of a bent LineString
calculate_dipping_angle_linestring
Calculate the dipping angle of a LineString
Note
The LineString must only consist of two points (start and end point)
- gemgis.vector.calculate_distance_linestrings(ls1: shapely.geometry.linestring.LineString, ls2: shapely.geometry.linestring.LineString) float #
Calculating the minimal distance between two LineStrings
- Parameters
ls1 (shapely.geometry.linestring.LineString) – LineString 1, e.g.
ls1 = LineString([(0, 0), (10, 10), (20, 20)])
ls2 (shapely.geometry.linestring.LineString) – LineString 2, e.g.
ls2 = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
distance – Minimum distance between two Shapely LineStrings
- Return type
float
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineStrings >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring1 = LineString([(0, 0), (20, 20)]) >>> linestring1.wkt 'LINESTRING (0 0, 20 20)'
>>> # Creating second LineString >>> linestring2 = LineString([(0, 10), (20, 30)]) >>> linestring2.wkt 'LINESTRING (0 10, 20 30)'
>>> # Calculating distance between LineStrings >>> distance = gg.vector.calculate_distance_linestrings(ls1=linestring1, ls2=linestring2) >>> distance 7.0710678118654755
See also
calculate_azimuth
Calculating the azimuth for orientations on a map
create_linestring_from_points
Create LineString from points
create_linestring_gdf
Create GeoDataFrame with LineStrings from points
extract_orientations_from_map
Extracting orientations from a map
calculate_orientations_from_strike_lines
Calculating the orientations from strike lines
- gemgis.vector.calculate_midpoint_linestring(linestring: shapely.geometry.linestring.LineString) shapely.geometry.point.Point #
Calculating the midpoint of a LineString with two vertices
- Parameters
linestring (shapely.geometry.linestring.LineString) – LineString consisting of two vertices from which the midpoint will be extracted, e.g.
linestring = LineString([(0, 0), (20, 20)])
- Returns
point – Shapely Point representing the midpoint of the LineString
- Return type
shapely.geometry.point.Point
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Calculating the midpoint of a LineString >>> midpoint = gg.vector.calculate_midpoint_linestring(linestring=linestring) >>> midpoint.wkt 'POINT (10 -10)'
See also
calculate_midpoints_linestrings
Calculating the midpoints of LineStrings
Note
The LineString must only consist of two points (start and end point)
- gemgis.vector.calculate_midpoints_linestrings(linestring_gdf: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) List[shapely.geometry.point.Point] #
Calculating the midpoints of LineStrings with two vertices each
- Parameters
linestring_gdf (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) – GeoDataFrame containing LineStrings or list of LineStrings of which the midpoints will be calculated
- Returns
midpoint_list – List of Shapely Points representing the midpoints of the provided LineStrings
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating list of LineStrings >>> linestring_list = [linestring, linestring]
>>> # Calculating midpoints from LineStrings >>> midpoints = gg.vector.calculate_midpoints_linestrings(linestring_gdf=linestring_list) >>> midpoints [<shapely.geometry.point.Point at 0x231ea982880>, <shapely.geometry.point.Point at 0x231ea982700>]
>>> # Inspecting the first element of the list >>> midpoints[0].wkt 'POINT (10 -10)'
>>> # Inspecting the second element of the list >>> midpoints[1].wkt 'POINT (10 -10)'
See also
calculate_midpoint_linestring
Calculating the midpoint of one LineString
- gemgis.vector.calculate_orientation_for_three_point_problem(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Calculating the orientation for a three point problem
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the three points and respective altitudes
- Returns
orientation – GeoDataFrame containing the calculated orientation value
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg >>> import geopandas as gpd >>> points = gpd.read_file(filename='points.shp') >>> points id formation Z geometry 0 None Coal 200 POINT (1842.732 602.462) 1 None Coal 400 POINT (1696.262 1775.038) 2 None Coal 600 POINT (104.302 1770.385)
>>> # Calculating Orientation >>> orientation = gg.vector.calculate_orientation_for_three_point_problem(gdf=points) >>> orientation Z formation azimuth dip polarity X Y geometry 0 400.0 Coal 140.84 11.29 1 1214.43 1382.63 POINT (1214.432 1382.628)
- gemgis.vector.calculate_orientation_from_bent_cross_section(profile_linestring: shapely.geometry.linestring.LineString, orientation_linestring: shapely.geometry.linestring.LineString) list #
Calculating the orientation of a LineString on a bent cross section provided as Shapely LineString
- Parameters
profile_linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map e.g.
profile_linestring = LineString([(0, 0), (5, 10), (20, 20)])
orientation_linestring (shapely.geometry.linestring.LineString) – Shapely LineString representing an orientation measurement on the cross section, e.g.
orientation_linestring = LineString([(2, -2), (5, -5)])
- Returns
orientation – List containing a Shapely Point with X and Y coordinates, the Z value, dip, azimuth and polarity values
- Return type
list
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> profile_linestring = LineString([(0, 0), (5, 10), (20, 20)]) >>> profile_linestring.wkt 'LINESTRING (0 0, 5 10, 20 20)'
>>> # Creating second LineString >>> orientation_linestring = LineString([(2, -2), (5, -5)]) >>> orientation_linestring.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Calculating the orientation from a bent cross section >>> orientations = gg.vector.calculate_orientation_from_bent_cross_section(profile_linestring=profile_linestring, orientation_linestring=orientation_linestring) >>> orientations [<shapely.geometry.point.Point at 0x231e7f00820>, -3.5, 45.0, 26.565051177078004, 1]
>>> # Inspecting the Point object of the list >>> orientations[0].wkt 'POINT (1.565247584249853 3.130495168499706)'
See also
calculate_orientation_from_cross_section
Calculating the orientation of a LineString on a cross section
calculate_orientations_from_cross_section
Calculating orientations for LineStrings on a cross section
extract_orientations_from_cross_sections
Calculating the orientations for LineStrings on cross sections
- gemgis.vector.calculate_orientation_from_cross_section(profile_linestring: shapely.geometry.linestring.LineString, orientation_linestring: shapely.geometry.linestring.LineString) list #
Calculating the orientation for one LineString on one cross sections
- Parameters
profile_linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
profile_linestring = LineString([(0, 0), (20, 20)])
orientation_linestring (shapely.geometry.linestring.LineString) – Shapely LineString representing an orientation measurement on the cross section e.g.
orientation_linestring = LineString([(2, -2), (5, -5)])
- Returns
orientation – List containing a Shapely Point with X and Y coordinates, the Z value, dip, azimuth and polarity values
- Return type
list
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> profile_linestring = LineString([(0, 0), (20, 20)]) >>> profile_linestring.wkt 'LINESTRING (0 0, 20 20)'
>>> # Creating second LineString >>> orientation_linestring = LineString([(2, -2), (5, -5)]) >>> orientation_linestring.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Calculating orientation orientation from cross section >>> orientations = gg.vector.calculate_orientation_from_cross_section(profile_linestring=profile_linestring, orientation_linestring=orientation_linestring) >>> orientations [<shapely.geometry.point.Point at 0x231e79a5370>, -3.5, 45.0, 45.0, 1]
>>> # Inspecting the Point object of the list >>> orientations[0].wkt 'POINT (2.474873734152916 2.474873734152916)'
See also
calculate_orientation_from_bent_cross_section
Calculating the orientation of a LineString on a bent cross section
calculate_orientations_from_cross_section
Calculating orientations for LineStrings on a cross section
extract_orientations_from_cross_sections
Calculating the orientations for LineStrings on cross sections
- gemgis.vector.calculate_orientations_from_cross_section(profile_linestring: shapely.geometry.linestring.LineString, orientation_linestrings: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]], extract_coordinates: bool = True) geopandas.geodataframe.GeoDataFrame #
Calculating orientations from a cross sections using multiple LineStrings
- Parameters
profile_linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
profile_linestring = LineString([(0, 0), (5, 10), (20, 20)])
orientations_linestrings (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.linestring.LineString]]) – GeoDataFrame or list containing multiple orientation LineStrings
extract_coordinates (bool) – Variable to extract the X and Y coordinates from point objects. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing the Shapely Points with X, Y coordinates, the Z value, dips, azimuths and polarities
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> profile_linestring = LineString([(0, 0), (5, 10), (20, 20)]) >>> profile_linestring.wkt 'LINESTRING (0 0, 5 10, 20 20)'
>>> # Creating second LineString >>> orientation_linestring = LineString([(2, -2), (5, -5)]) >>> orientation_linestring.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Creating List of LineStrings >>> orientations_list = [orientation_linestring, orientation_linestring]
>>> # Calculating orientations from cross sections >>> orientations = gg.vector.calculate_orientations_from_cross_section(profile_linestring=profile_linestring, orientation_linestrings=orientations_list) >>> orientations X Y Z dip azimuth polarity geometry 0 1.57 3.13 -3.50 45.00 26.57 1.00 POINT (1.56525 3.13050) 1 1.57 3.13 -3.50 45.00 26.57 1.00 POINT (1.56525 3.13050)
See also
calculate_orientation_from_cross_section
Calculating the orientation of a LineString on a cross section
calculate_orientation_from_bent_cross_section
Calculating orientations of a LineStrings on a bent cross section
extract_orientations_from_cross_sections
Calculating the orientations for LineStrings on cross sections
- gemgis.vector.calculate_orientations_from_strike_lines(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Calculating orientations based on LineStrings representing strike lines
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing LineStrings representing strike lines
- Returns
gdf_orient – GeoDataFrame containing the location of orientation measurements and their associated orientation values
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Changed in version 1.1.7.
Fixing indexing issue.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> import geopandas as gpd >>> linestring1 = LineString([(0, 0), (20, 20)]) >>> linestring1.wkt 'LINESTRING (0 0, 20 20)'
>>> # Create second LineString >>> linestring2 = LineString([(0, 10), (20, 30)]) >>> linestring2.wkt 'LINESTRING (0 10, 20 30)'
>>> # Creating GeoDataFrame from LineStrings >>> gdf = gpd.GeoDataFrame(geometry=[linestring1, linestring2]) >>> gdf['Z'] = [100,200] >>> gdf['id'] = [1,2] >>> gdf geometry Z id 0 LINESTRING (0.0 0.0, 20.0 20.0) 100 1 1 LINESTRING (0.0 10.0, 20.0 30.0) 200 2
>>> # Calculating orientations strike lines >>> orientations = gg.vector.calculate_orientations_from_strike_lines(gdf=gdf) >>> orientations dip azimuth Z geometry polarity X Y 0 85.96 135.00 150.00 POINT (10.0 15.0) 1.00 10.00 15.00
See also
calculate_azimuth
Calculating the azimuth for orientations on a map
create_linestring_from_points
Create LineString from points
create_linestring_gdf
Create GeoDataFrame with LineStrings from points
extract_orientations_from_map
Extracting orientations from a map
calculate_distance_linestrings
Calculating the distance between two LineStrings
- gemgis.vector.calculate_strike_direction_bent_linestring(linestring: shapely.geometry.linestring.LineString) List[float] #
Calculating the strike direction of a LineString with multiple elements
- Parameters
linestring (linestring: shapely.geometry.linestring.LineString) – Shapely LineString containing more than two vertices, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
angles_splitted_linestrings – List containing the strike angles of each line segment of the original
- Return type
List[float]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Calculating the strike angles for LineString elements >>> angles = gg.vector.calculate_strike_direction_bent_linestring(linestring=linestring) >>> angles [45.0, 45.0]
See also
calculate_angle
Calculating the angle of a LineString
calculate_strike_direction_straight_linestring
Calculating the strike direction of a straight LineString
calculate_dipping_angle_linestring
Calculate the dipping angle of a LineString
calculate_dipping_angles_linestrings
Calculate the dipping angles of LineStrings
- gemgis.vector.calculate_strike_direction_straight_linestring(linestring: shapely.geometry.linestring.LineString) float #
Function to calculate the strike direction of a straight Shapely LineString. The strike will always be calculated from start to end point
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString representing the surface trace of a straight geological profile, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
angle – Strike angle calculated from start to end point for a straight Shapely LineString
- Return type
float
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 20)'
>>> # Calculating the strike angle of the LineString >>> angle = gg.vector.calculate_strike_direction_straight_linestring(linestring=linestring) >>> angle 45.0
See also
calculate_angle
Calculating the angle of a LineString
calculate_strike_direction_bent_linestring
Calculating the strike direction of a bent LineString
calculate_dipping_angle_linestring
Calculate the dipping angle of a LineString
calculate_dipping_angles_linestrings
Calculate the dipping angles of LineStrings
Note
The LineString must only consist of two points (start and end point)
- gemgis.vector.clip_by_bbox(gdf: geopandas.geodataframe.GeoDataFrame, bbox: List[Union[int, float]], reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True) geopandas.geodataframe.GeoDataFrame #
Clipping vector data contained in a GeoDataFrame to a provided bounding box/extent
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing vector data that will be clipped to a provided bounding box/extent
bbox (List[Union[float, int]]) – Bounding box of minx, maxx, miny, maxy values to clip the GeoDataFrame, , e.g.
bbox=[0, 972, 0, 1069]
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing vector data clipped by a bounding box
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id geometry 0 None POINT (281.526 902.087) 1 None POINT (925.867 618.577) 2 None POINT (718.131 342.799) 3 None POINT (331.011 255.684) 4 None POINT (300.083 600.535)
>>> # Returning the length of the original gdf >>> len(gdf) 50
>>> # Defining bounding box >>> bbox = [0,972, 0, 1069]
>>> # Clipping data by bounding box >>> gdf_clipped = gg.vector.clip_by_bbox(gdf=gdf, bbox=bbox) >>> gdf_clipped geometry X Y 0 POINT (281.526 902.087) 281.53 902.09 1 POINT (925.867 618.577) 925.87 618.58 2 POINT (718.131 342.799) 718.13 342.80 3 POINT (331.011 255.684) 331.01 255.68 4 POINT (300.083 600.535) 300.08 600.54
>>> # Returning the length of the clipped gdf >>> len(gdf_clipped) 25
See also
clip_by_polygon
Clipping vector data with a Shapely Polygon
- gemgis.vector.clip_by_polygon(gdf: geopandas.geodataframe.GeoDataFrame, polygon: shapely.geometry.polygon.Polygon, reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True) geopandas.geodataframe.GeoDataFrame #
Clipping vector data contained in a GeoDataFrame to a provided bounding box/extent
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing vector data that will be clipped to a provided bounding box/extent
polygon (polygon: shapely.geometry.polygon) – Shapely Polygon defining the extent of the data, e.g.
polygon = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing vector data clipped by a bounding box
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id geometry 0 None POINT (281.526 902.087) 1 None POINT (925.867 618.577) 2 None POINT (718.131 342.799) 3 None POINT (331.011 255.684) 4 None POINT (300.083 600.535)
>>> # Returning the length of the original gdf >>> len(gdf) 50
>>> # Creating Shapely Polygon >>> from shapely.geometry import Polygon >>> polygon = Polygon([(0,0),(972, 0), (972,1069), (0, 1069)]) >>> polygon.wkt 'POLYGON ((0 0, 972 0, 972 1069, 0 1069, 0 0))'
>>> # Clipping data by the polygon >>> gdf_clipped = gg.vector.clip_by_polygon(gdf=gdf, polygon=polygon) >>> gdf_clipped geometry X Y 0 POINT (281.526 902.087) 281.53 902.09 1 POINT (925.867 618.577) 925.87 618.58 2 POINT (718.131 342.799) 718.13 342.80 3 POINT (331.011 255.684) 331.01 255.68 4 POINT (300.083 600.535) 300.08 600.54
>>> # Returning the length of the clipped gdf >>> len(gdf_clipped) 25
See also
clip_by_bbox
Clipping vector data with a bbox
- gemgis.vector.create_bbox(extent: List[Union[int, float]]) shapely.geometry.polygon.Polygon #
Creating a rectangular polygon from the provided bounding box values, with counter-clockwise order by default.
- Parameters
extent (List[Union[int, float]]) – List of minx, maxx, miny, maxy values, e.g.
extent=[0, 972, 0, 1069]
- Returns
bbox – Rectangular polygon based on extent
- Return type
shapely.geometry.polygon.Polygon
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg
>>> # Defining extent >>> extent = [0, 972, 0, 1069]
>>> # Creating bounding box >>> bbox = gg.vector.create_bbox(extent=extent) >>> bbox.wkt 'POLYGON ((972 0, 972 1069, 0 1069, 0 0, 972 0))'
- gemgis.vector.create_buffer(geom_object: shapely.geometry.base.BaseGeometry, distance: Union[float, int]) shapely.geometry.polygon.Polygon #
Creating a buffer around a Shapely LineString or a Point
- Parameters
geom_object (shapely.geometry.base.BaseGeometry) – Shapely LineString or Point, e.g.
geom_object=Point(0, 0)
distance (float, int) – Distance of the buffer around the geometry object, e.g.
distance=10
- Returns
polygon – Polygon representing the buffered area around a geometry object
- Return type
shapely.geometry.polygon.Polygon
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Point >>> import gemgis as gg >>> from shapely.geometry import Point >>> point = Point(0,0) >>> point.wkt 'POINT (0 0)'
>>> # Creating Buffer around Point >>> point_buffered = gg.vector.create_buffer(geom_object=point, distance=10) >>> point_buffered.wkt 'POLYGON ((100 0, 99.5184726672197 -9.801714032956051, 98.07852804032305 -19.50903220161281, 95.69403357322089 -29.02846772544621, 92.38795325112869 -38.26834323650894, 88.19212643483553...))'
See also
create_unified_buffer
Creating a unified buffer around Shapely LineStrings or Points
- gemgis.vector.create_hexagon(center: shapely.geometry.point.Point, radius: Union[int, float])#
Function to create one hexagon
- Parameters
center (shapely.geometry.Point) – Shapely Point representing the center of the hexagon
radius (int, float) – Radius of the hexagon
- Returns
geometry.Polygon(hex_coords) – Shapley Polygon in the shape of a hexagon
- Return type
shapely.geometry.Polygon
New in version 1.0.x.
Changed in version 1.1.3: Optimized creation of hexagon
See also
create_hexagon_grid
Creating a hexagon grid
- gemgis.vector.create_hexagon_grid(gdf: geopandas.geodataframe.GeoDataFrame, radius: Union[int, float], crop_gdf: bool = True)#
Function to create a grid of hexagons based on a GeoDataFrame containing Polygons and a radius provided for the single hexagons
- Parameters
gdf (gpd.GeoDataFrame) – GeoDataFrame containing the polygons for which a hexagon grid is created
radius (int, float) – Radius of the hexagon
crop_gdf (bool) – Boolean to define if the resulting GeoDataFrame should be cropped to the extend of the provided GeoDataFrame Options include:
True
orFalse
, default set toTrue
- Returns
hex_gdf – GeoDataFrame containing the hexagon grid
- Return type
gpd.GeoDataFrame
New in version 1.0.x.
Changed in version 1.1.3: Optimized creation of hexagon
See also
create_hexagon
Creating one hexagon based on a given center and radius
- gemgis.vector.create_linestring_from_points(gdf: geopandas.geodataframe.GeoDataFrame, formation: str, altitude: Union[int, float]) shapely.geometry.linestring.LineString #
Creating a LineString object from a GeoDataFrame containing surface points at a given altitude and for a given formation
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the points of intersections between topographic contours and layer boundaries
formation (str) – Name of the formation, e.g.
formation='Layer1'
altitude (Union[int, float]) – Value of the altitude of the points, e.g.
altitude=100
- Returns
linestring – LineString containing a LineString object
- Return type
shapely.geometry.linestring.LineString
New in version 1.0.x.
Example
>>> # Loading Libraries and creating points >>> import gemgis as gg >>> from shapely.geometry import Point >>> import geopandas as gpd >>> point1 = Point(0,0) >>> point2 = Point (10,10)
>>> # Creating GeoDataFrame from points and adding additional information >>> gdf = gpd.GeoDataFrame(geometry=[point1, point2]) >>> gdf['formation'] = 'Layer1' >>> gdf['Z'] = 100 >>> gdf geometry formation Z 0 POINT (0.0 0.0) Layer1 100 1 POINT (10.0 10.0) Layer1 100
>>> # Creating LineString from Points >>> linestring = gg.vector.create_linestring_from_points(gdf=gdf, formation='Layer1', altitude=100) >>> linestring.wkt 'LINESTRING (0 0, 10 10)'
See also
calculate_azimuth
Calculating the azimuth for orientations on a map
create_linestring_gdf
Create GeoDataFrame with LineStrings from points
extract_orientations_from_map
Extracting orientations from a map
calculate_distance_linestrings
Calculating the distance between LineStrings
calculate_orientations_from_strike_lines
Calculating the orientations from strike lines
- gemgis.vector.create_linestring_from_xyz_points(points: Union[numpy.ndarray, geopandas.geodataframe.GeoDataFrame], nodata: Union[int, float] = 9999.0, xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z', drop_nan: bool = True) shapely.geometry.linestring.LineString #
Create LineString from an array or GeoDataFrame containing X, Y, and Z coordinates of points.
- Parameters
points (Union[np.ndarray, gpd.geodataframe.GeoDataFrame]) – NumPy Array or GeoDataFrame containing XYZ points.
nodata (Union[int, float])) – Nodata value to filter out points outside a designated area, e.g.
nodata=9999.0
, default is9999.0
.xcol (str) – Name of the X column in the dataset, e.g.
xcol='X'
, default is'X'
.ycol (str) – Name of the Y column in the dataset, e.g.
ycol='Y'
, default is'Y'
.zcol (str) – Name of the Z column in the dataset, e.g.
zcol='Z'
, default is'Z'
.drop_nan (bool) – Boolean argument to drop points that contain a
nan
value as Z value. Options includeTrue
andFalse
, default isTrue
.
- Returns
line – LineString Z constructed from provided point values
- Return type
shapely.geometry.linestring.LineString
New in version 1.0.x.
Changed in version 1.1: Adding argument drop_nan and code to drop coordinates that contain
nan
values as Z coordinates.Example
>>> # Loading Libraries and creating points >>> import gemgis as gg >>> import numpy as np >>> points = np.array([[3.23, 5.69, 2.03],[3.24, 5.68, 2.02],[3.25, 5.67, 1.97],[3.26, 5.66, 1.95]])
>>> # Creating LineStrings from points >>> linestring = gg.vector.create_linestring_from_xyz_points(points=points) >>> linestring.wkt 'LINESTRING Z (3.23 5.69 2.03, 3.24 5.68 2.02, 3.25 5.67 1.97, 3.26 5.66 1.95)'
- gemgis.vector.create_linestring_gdf(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Creating LineStrings from Points
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the points of intersections between topographic contours and layer boundaries
- Returns
gdf_linestring – GeoDataFrame containing LineStrings
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Points >>> import gemgis as gg >>> from shapely.geometry import Point >>> import geopandas as gpd >>> point1 = Point(0,0) >>> point2 = Point (10,10)
>>> # Creating GeoDataFrame from points and adding additional information >>> gdf = gpd.GeoDataFrame(geometry=[point1, point2]) >>> gdf['formation'] = 'Layer1' >>> gdf['Z'] = 100 >>> gdf['id'] = 1 >>> gdf geometry formation Z id 0 POINT (0.0 0.0) Layer1 100 1 1 POINT (10.0 10.0) Layer1 100 1
>>> # Creating LineString GeoDataFrame >>> linestring_gdf = gg.vector.create_linestring_gdf(gdf=gdf) >>> linestring_gdf index formation Z id geometry 0 0 Layer1 100 1 LINESTRING (0.00000 0.00000, 10.00000 10.00000)
See also
calculate_azimuth
Calculating the azimuth for orientations on a map
create_linestring_from_points
Create LineString from points
extract_orientations_from_map
Extracting orientations from a map
calculate_distance_linestrings
Calculating the distance between LineStrings
calculate_orientations_from_strike_lines
Calculating the orientations from strike lines
- gemgis.vector.create_linestrings_from_contours(contours: pyvista.core.pointset.PolyData, return_gdf: bool = True, crs: Union[str, pyproj.crs.crs.CRS] = None) Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame] #
Creating LineStrings from PyVista Contour Lines and save them as list or GeoDataFrame
- Parameters
contours (pv.core.pointset.PolyData) – PyVista PolyData dataset containing contour lines extracted from a mesh
return_gdf (bool) – Variable to create GeoDataFrame of the created list of Shapely Objects. Options include:
True
orFalse
, default set toTrue
crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
crs='EPSG:4647'
- Returns
linestrings – List of LineStrings or GeoDataFrame containing the contours that were converted
- Return type
Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pyvista as pv >>> contours = pv.read('file.vtk') >>> contours Header PolyData Information N Cells 36337 N Points 36178 X Bounds 3.233e+07, 3.250e+07 Y Bounds 5.704e+06, 5.798e+06 Z Bounds -2.400e+03, 3.500e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Depth [m] Points float64 1 -2.400e+03 3.500e+02
>>> # Extracting LineStrings from contours >>> gdf = gg.vector.create_linestrings_from_contours(contours=contours) >>> gdf geometry Z 0 LINESTRING Z (32409587.930 5780538.824 -2350.0... -2350.00 1 LINESTRING Z (32407304.336 5777048.086 -2050.0... -2050.00 2 LINESTRING Z (32408748.977 5778005.047 -2200.0... -2200.00 3 LINESTRING Z (32403693.547 5786613.994 -2400.0... -2400.00 4 LINESTRING Z (32404738.664 5782672.480 -2350.0... -2350.00
- gemgis.vector.create_linestrings_from_xyz_points(gdf: geopandas.geodataframe.GeoDataFrame, groupby: str, nodata: Union[int, float] = 9999.0, xcol: str = 'X', ycol: str = 'Y', zcol: str = 'Z', dem: Union[numpy.ndarray, rasterio.io.DatasetReader] = None, extent: List[Union[int, float]] = None, return_gdf: bool = True, drop_nan: bool = True) Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame] #
Creating LineStrings from a GeoDataFrame containing X, Y, and Z coordinates of vertices of multiple LineStrings
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing extracted X, Y, and Z coordinates of LineStrings
groupby (str) – Name of a unique identifier the LineStrings can be separated from each other, e.g.
groupby='Object_ID'
nodata (Union[int, float])) – Nodata value to filter out points outside a designated area, e.g.
nodata=9999.0
, default is9999.0
xcol (str) – Name of the X column in the dataset, e.g.
xcol='X'
, default is'X'
ycol (str) – Name of the Y column in the dataset, e.g.
ycol='Y'
, default is'Y'
zcol (str) – Name of the Z column in the dataset, e.g.
zcol='Z'
, default is'Z'
dem (Union[np.ndarray, rasterio.io.DatasetReader]) – NumPy ndarray or rasterio object containing the height values, default value is
None
in case geometries contain Z valuesextent (List[Union[float, int]]) – Values for minx, maxx, miny and maxy values to define the boundaries of the raster, e.g.
extent=[0, 972, 0, 1069]
return_gdf (bool) – Variable to either return the data as GeoDataFrame or as list of LineStrings. Options include:
True
orFalse
, default set toTrue
drop_nan (bool) – Boolean argument to drop points that contain a
nan
value as Z value. Options includeTrue
andFalse
, default isTrue
- Returns
linestrings – List of LineStrings or GeoDataFrame containing the LineStrings with Z component
- Return type
Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Changed in version 1.1: Removed manual dropping of additional columns. Now automatically drops unnecessary coloumns. Adding argument drop_nan and code to drop coordinates that contain
nan
values as Z coordinates.Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf
>>> # Creating LineStrings with Z component from gdf >>> gdf_linestring = gg.vector.create_linestrings_from_xyz_points(gdf=gdf, groupby='ABS') >>> gdf_linestring
- gemgis.vector.create_polygons_from_faces(mesh: pyvista.core.pointset.PolyData, crs: Union[str, pyproj.crs.crs.CRS], return_gdf: bool = True) Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame] #
Extracting faces from PyVista PolyData as Shapely Polygons
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista PolyData dataset
crs – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
crs='EPSG:4647'
- Returns
polygons – Triangular Shapely Polygons representing the faces of the mesh
- Return type
Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Example
>>> # Importing Libraries and File >>> import gemgis as gg >>> import pyvista as pv >>> mesh = pv.read(filename='mesh.vtk') >>> mesh Header PolyData Information N Cells 29273 N Points 40343 X Bounds 2.804e+05, 5.161e+05 Y Bounds 5.640e+06, 5.833e+06 Z Bounds -8.067e+03, 1.457e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Depth [m] Points float64 1 -8.067e+03 1.457e+02
>>> # Create polygons from mesh faces >>> polygons = gg.vector.create_polygons_from_faces(mesh=mesh) >>> polygons geometry 0 POLYGON Z ((297077.414 5677487.262 -838.496, 2... 1 POLYGON Z ((298031.070 5678779.547 -648.688, 2... 2 POLYGON Z ((297437.539 5676992.094 -816.608, 2... 3 POLYGON Z ((298031.070 5678779.547 -648.688, 2... 4 POLYGON Z ((295827.680 5680951.574 -825.328, 2...
- gemgis.vector.create_unified_buffer(geom_object: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.base.BaseGeometry]], distance: Union[numpy.ndarray, List[Union[int, float]], float, int]) shapely.geometry.multipolygon.MultiPolygon #
Creating a unified buffer around Shapely LineStrings or Points
- Parameters
geom_object (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.base.BaseGeometry]]) – GeoDataFrame or List of Shapely objects
distance (Union[np.ndarray, List[Union[float, int]], Union[float, int]]) – Distance of the buffer around the geometry object, e.g.
distance=10
- Returns
polygon – Polygon representing the buffered area around a geometry object
- Return type
shapely.geometry.multipolygon.MultiPolygon
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Point >>> import gemgis as gg >>> from shapely.geometry import Point >>> point1 = Point(0,0) >>> point1.wkt 'POINT (0 0)'
>>> # Creating Point >>> point2 = Point(20,20) >>> point2.wkt 'POINT (20 20)'
>>> # Creating list of points >>> point_list = [point1, point2]
>>> # Creating unified buffer >>> unified_buffer = gg.vector.create_unified_buffer(geom_object=point_list, distance=10) >>> unified_buffer 'MULTIPOLYGON (((10 0, 9.95184726672197 -0.980171403295605, 9.807852804032306 -1.950903220161281, 9.56940335732209 -2.902846772544621, 9.23879532511287 -3.826834323650894,...)))'
See also
create_buffer
Creating a buffer around a Shapely LineString or Point
- gemgis.vector.create_voronoi_polygons(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Function to create Voronoi Polygons from Point GeoDataFrame using the SciPy Spatial Voronoi class (https://docs.scipy.org/doc/scipy/reference/generated/scipy.spatial.Voronoi.html#scipy.spatial.Voronoi)
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the Shapely Points
- Returns
gdf_polygons – GeoDataFrame containing the valid Voronoi Polygons
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.1.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file('file.shp') >>> gdf_polygons = gg.vector.create_voronoi_polygons(gdf=gdf)
- gemgis.vector.explode_geometry_collection(collection: shapely.geometry.collection.GeometryCollection) List[shapely.geometry.base.BaseGeometry] #
Exploding a Shapely Geometry Collection to a List of Base Geometries
- Parameters
collection (shapely.geometry.collection.GeometryCollection) – Shapely Geometry Collection consisting of different Base Geometries
- Returns
collection_exploded – List of Base Geometries from the original Geometry Collection
- Return type
List[shapely.geometry.base.BaseGeometry]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Geometry Collection >>> import gemgis as gg >>> from shapely.geometry import LineString >>> a = LineString([(0, 0), (1, 1), (1,2), (2,2)]) >>> b = LineString([(0, 0), (1, 1), (2,1), (2,2)]) >>> collection = a.intersection(b) >>> collection.wkt 'GEOMETRYCOLLECTION (POINT (2 2), LINESTRING (0 0, 1 1))'
>>> # Exploding Geometry collection into single Base Geometries >>> collection_exploded = gg.vector.explode_geometry_collection(collection=collection) >>> collection_exploded [<shapely.geometry.point.Point at 0x1faf63ccac0>, <shapely.geometry.linestring.LineString at 0x1faf63ccb80>]
>>> # Inspecting the first element of the list >>> collection_exploded[0].wkt 'POINT (2 2)'
>>> # Inspecting the second element of the list >>> collection_exploded[1].wkt 'LINESTRING (0 0, 1 1)'
See also
explode_geometry_collections
Exploding a GeoDataFrame containing different Base Geometries
- gemgis.vector.explode_geometry_collections(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_level0: bool = True, drop_level1: bool = True, remove_points: bool = True) geopandas.geodataframe.GeoDataFrame #
Exploding Shapely Geometry Collections stored in GeoDataFrames to different Shapely Base Geometries
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type GeometryCollection
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
remove_points (bool) – Variable to remove points from exploded GeoDataFrame. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing different geometry types
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Geometries >>> import gemgis as gg >>> from shapely.geometry import LineString, Polygon >>> import geopandas as gpd >>> a = LineString([(0, 0), (1, 1), (1,2), (2,2)]) >>> b = LineString([(0, 0), (1, 1), (2,1), (2,2)]) >>> collection = a.intersection(b) >>> polygon = Polygon([(0, 0), (10, 0), (10, 10), (0, 10)])
>>> # Creating GeoDataFrame from Base Geometries >>> gdf = gpd.GeoDataFrame(geometry=[a, b, collection, polygon]) >>> gdf geometry 0 LINESTRING (0.00000 0.00000, 1.00000 1.00000, ... 1 LINESTRING (0.00000 0.00000, 1.00000 1.00000, ... 2 GEOMETRYCOLLECTION (POINT (2.00000 2.00000), L... 3 POLYGON ((0.00000 0.00000, 10.00000 0.00000, 1..
>>> # Explode Geometry Collection into single Base Geometries >>> gdf_exploded = gg.vector.explode_geometry_collections(gdf=gdf) >>> gdf_exploded geometry 0 LINESTRING (0.00000 0.00000, 1.00000 1.00000, ... 1 LINESTRING (0.00000 0.00000, 1.00000 1.00000, ... 2 LINESTRING (0.00000 0.00000, 1.00000 1.00000) 3 POLYGON ((0.00000 0.00000, 10.00000 0.00000, 1...
See also
explode_geometry_collection
Exploding a Shapely Geometry Collection Object into a list of Base Geometries
- gemgis.vector.explode_linestring(linestring: shapely.geometry.linestring.LineString) List[shapely.geometry.point.Point] #
Exploding a LineString to its vertices, also works for LineStrings with Z components
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString from which vertices are extracted, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
points_list – List of extracted Shapely Points
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Exploding LineString into single points >>> linestring_exploded = gg.vector.explode_linestring(linestring=linestring) >>> linestring_exploded [<shapely.geometry.point.Point at 0x20118cb27f0>, <shapely.geometry.point.Point at 0x20118cb28b0>, <shapely.geometry.point.Point at 0x20118cb26d0>]
>>> # Inspecting the first element of the list >>> linestring_exploded[0].wkt 'POINT (0 0)'
>>> # Inspecting the second element of the list >>> linestring_exploded[1].wkt 'POINT (10 10)'
>>> # Inspecting the third element of the list >>> linestring_exploded[2].wkt 'POINT (20 20)'
See also
explode_linestring_to_elements
Exploding a LineString with more than two vertices into single LineStrings
- gemgis.vector.explode_linestring_to_elements(linestring: shapely.geometry.linestring.LineString) List[shapely.geometry.linestring.LineString] #
Separating a LineString into its single elements and returning a list of LineStrings representing these elements, also works for LineStrings with Z components
- Parameters
linestring (linestring: shapely.geometry.linestring.LineString) – Shapely LineString containing more than two vertices, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
- Returns
splitted_linestrings – List containing the separate elements of the original LineString stored as LineStrings
- Return type
List[shapely.geometry.linestring.LineString]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Exploding LineString into single elements >>> linestring_exploded = gg.vector.explode_linestring_to_elements(linestring=linestring) >>> linestring_exploded [<shapely.geometry.linestring.LineString at 0x201448a2100>, <shapely.geometry.linestring.LineString at 0x20144b5e610>]
>>> # Inspecting the first element of the list >>> linestring_exploded[0].wkt 'LINESTRING (0 0, 10 10)'
>>> # Inspecting the second element of the list >>> linestring_exploded[1].wkt 'LINESTRING (10 10, 20 20)'
See also
explode_linestring
Exploding a LineString into its single vertices
- gemgis.vector.explode_multilinestring(multilinestring: shapely.geometry.multilinestring.MultiLineString) List[shapely.geometry.linestring.LineString] #
Exploding a MultiLineString into a list of LineStrings
- Parameters
multilinestring (shapely.geometry.multilinestring.MultiLineString) – Shapely MultiLineString consisting of multiple LineStrings, e.g.
multilinestring = MultiLineString([((0, 0), (1, 1)), ((-1, 0), (1, 0))])
- Returns
splitted_multilinestring – List of Shapely LineStrings
- Return type
List[shapely.geometry.linestring.LineString]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating MultiLineString >>> import gemgis as gg >>> from shapely.geometry import MultiLineString >>> coords = [((0, 0), (1, 1)), ((-1, 0), (1, 0))] >>> lines = MultiLineString(coords) >>> lines.wkt 'MULTILINESTRING ((0 0, 1 1), (-1 0, 1 0))'
>>> lines_splitted = gg.vector.explode_multilinestrings(multilinestring=lines) >>> lines_splitted [<shapely.geometry.linestring.LineString at 0x2014a5f0ee0>, <shapely.geometry.linestring.LineString at 0x20149dda430>]
>>> # Inspecting the first element of the list >>> lines_splitted[0].wkt 'LINESTRING (0 0, 1 1)'
>>> # Inspecting the second element of the list >>> lines_splitted[1].wkt 'LINESTRING (-1 0, 1 0)'
See also
explode_multilinestrings
Exploding a GeoDataFrame containing MultiLineStrings into a GeoDataFrame containing LineStrings only
- gemgis.vector.explode_multilinestrings(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_level0: bool = True, drop_level1: bool = True) geopandas.geodataframe.GeoDataFrame #
Exploding Shapely MultiLineStrings stored in a GeoDataFrame to Shapely LineStrings
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type MultiLineString
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing LineStrings
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf geometry 0 MULTILINESTRING ((0.0 0.0, 1.0 1.0)) 1 MULTILINESTRING ((0.0 0.0, 1.0 1.0))
>>> # Exploding MultiLineStrings into single LineStrings >>> gdf_linestrings = gg.vector.explode_multilinestrings(gdf=gdf, reset_index=True) >>> gdf_linestrings geometry 0 LINESTRING (0.0 0.0, 1.0 1.0) 1 LINESTRING (-1.0 0.0, 1.0 0.0) 2 LINESTRING (0.0 0.0, 1.0 1.0) 3 LINESTRING (-1.0 0.0, 1.0 0.0)
See also
explode_multilinestring
Exploding a MultiLineString into a list of single LineStrings
- gemgis.vector.explode_polygon(polygon: shapely.geometry.polygon.Polygon) List[shapely.geometry.point.Point] #
Exploding Shapely Polygon to list of Points
- Parameters
polygon (shapely.geometry.polygon.Polygon) – Shapely Polygon from which vertices are extracted, e.g.
polygon = Polygon([(0, 0), (1, 1), (1, 0)])
- Returns
point_list – List containing the vertices of a polygon as Shapely Points
- Return type
List[shapely.geometry.point.Point]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon = Polygon([(0, 0), (1, 1), (1, 0)]) >>> polygon.wkt 'POLYGON ((0 0, 1 1, 1 0, 0 0))'
>>> # Exploding Polygon into single Points >>> polygon_exploded = gg.vector.explode_polygon(polygon=polygon) >>> polygon_exploded [<shapely.geometry.point.Point at 0x201459734f0>, <shapely.geometry.point.Point at 0x20145973670>, <shapely.geometry.point.Point at 0x20145973640>, <shapely.geometry.point.Point at 0x201459732e0>]
>>> # Inspecting the first element of the list >>> polygon_exploded[0].wkt 'POINT (0 0)'
>>> # Inspecting the second element of the list >>> polygon_exploded[1].wkt 'POINT (1 1)'
See also
explode_polygons
Exploding a GeoDataFrame containing Polygons into a GeoDataFrame containing LineStrings
- gemgis.vector.explode_polygons(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Converting a GeoDataFrame containing elements of geom_type Polygons to a GeoDataFrame with LineStrings
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type Polygon
- Returns
gdf_linestrings – GeoDataFrame containing elements of type MultiLineString and LineString
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf geometry 0 POLYGON ((0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0)) 1 POLYGON ((0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0))
>>> # Exploding Polygons into LineStrings >>> gdf_exploded = gg.vector.explode_polygons(gdf=gdf) >>> gdf_exploded geometry 0 LINESTRING (0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0) 1 LINESTRING (0.0 0.0, 1.0 1.0, 1.0 0.0, 0.0 0.0)
See also
explode_polygon
Exploding a Polygon into single Points
- gemgis.vector.extract_interfaces_coordinates_from_cross_section(linestring: shapely.geometry.linestring.LineString, interfaces_gdf: geopandas.geodataframe.GeoDataFrame, extract_coordinates: bool = True) geopandas.geodataframe.GeoDataFrame #
Extracting coordinates of interfaces digitized on a cross section
- Parameters
linestring (shapely.geometry.linestring.LineString) – Shapely LineString containing the trace of a cross section on a map, e.g.
linestring = LineString([(0, 0), (20, 20)])
interfaces_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the LineStrings of interfaces digitized on a cross section
- Returns
gdf – GeoDataFrame containing the extracted coordinates, depth/elevation data and additional columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> import geopandas as gpd >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating second LineString >>> interfaces = LineString([(2, -2), (5, -5)]) >>> interfaces.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Creating GeoDataFrame from LineString >>> gdf = gpd.GeoDataFrame(geometry=[interfaces, interfaces]) >>> gdf geometry 0 LINESTRING (2.0 -2.0, 5.0 -5.0) 1 LINESTRING (2.0 -2.0, 5.0 -5.0)
>>> # Extracting interfaces coordinates from cross sections >>> gdf_points = gg.vector.extract_interfaces_coordinates_from_cross_section(linestring=linestring, interfaces_gdf=gdf) >>> gdf_points geometry X Y Z 0 POINT (1.41421 -1.41421) 1.41 -1.41 -2.00 1 POINT (3.53553 -3.53553) 3.54 -3.54 -5.00 2 POINT (1.41421 -1.41421) 1.41 -1.41 -2.00 3 POINT (3.53553 -3.53553) 3.54 -3.54 -5.00
See also
calculate_coordinates_for_point_on_cross_section
Calculating the coordinates for a Point on a cross section
calculate_coordinates_for_linestring_on_cross_sections
Calculating the coordinates for one LineString on cross sections
calculate_coordinates_for_linestrings_on_cross_sections
Calculating the coordinates for LineStrings on cross sections
extract_xyz_from_cross_sections
Extracting the X, Y, and Z coordinates of interfaces from cross sections
- gemgis.vector.extract_orientations_from_cross_sections(profile_gdf: geopandas.geodataframe.GeoDataFrame, orientations_gdf: geopandas.geodataframe.GeoDataFrame, profile_name_column: str = 'name') geopandas.geodataframe.GeoDataFrame #
Calculating orientations digitized from cross sections
- Parameters
profile_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the different profile traces as LineStrings
orientations_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the orientation LineStrings for different profiles and formations
profile_name_column (str) – Name of the profile column, e.g.
profile_name_column='name'
, default is'name'
- Returns
gdf – GeoDataFrame containing the orientation and location data for orientations digitized on cross sections
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> import geopandas as gpd >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating GeoDataFrame from LineString and adding profile names >>> profile_gdf = gpd.GeoDataFrame(geometry=[linestring, linestring]) >>> profile_gdf['name'] = ['Profile2', 'Profile1'] >>> profile_gdf geometry name 0 LINESTRING (0.0 0.0, 20.0 -20.0) Profile2 1 LINESTRING (0.0 0.0, 20.0 -20.0) Profile1
>>> # Creating second LineString >>> orientation_linestring = LineString([(2, -2), (5, -5)]) >>> orientation_linestring.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Creating GeoDataFrame from LineString and adding profile names >>> orientations_gdf = gpd.GeoDataFrame(geometry=[orientation_linestring, orientation_linestring]) >>> orientations_gdf geometry name 0 LINESTRING (2.0 -2.0, 5.0 -5.0) Profile2 1 LINESTRING (2.0 -2.0, 5.0 -5.0) Profile1
>>> # Extract orientations from cross sections >>> orientations = gg.vector.extract_orientations_from_cross_sections(profile_gdf=profile_gdf, orientations_gdf=orientations_gdf) >>> orientations X Y Z dip azimuth polarity geometry name 0 2.47 -2.47 -3.50 45.00 135.00 1.00 POINT (2.47487 -2.47487) Profile2 1 2.47 -2.47 -3.50 45.00 135.00 1.00 POINT (2.47487 -2.47487) Profile1
- gemgis.vector.extract_orientations_from_map(gdf: geopandas.geodataframe.GeoDataFrame, dz: str = 'dZ') geopandas.geodataframe.GeoDataFrame #
Calculating orientations from LineStrings
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the orientation LineStrings
dz (str) – Name of the height difference column, e.g.
dz='dZ'
- Returns
gdf – GeoDataFrame containing the orientation values
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> import geopandas as gpd >>> linestring1 = LineString([(0, 0), (20, -20)]) >>> linestring1.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating second LineString >>> linestring2 = LineString([(0, 0), (20, -10)]) >>> linestring2.wkt 'LINESTRING (0 0, 20 -10)'
>>> # Creating GeoDataFrame from LineStrings >>> gdf = gpd.GeoDataFrame(geometry=[linestring1, linestring2]) >>> gdf['dZ'] = [100, 200] >>> gdf geometry dz 0 LINESTRING (0.0 0.0, 20.0 -20.0) 100 1 LINESTRING (0.0 0.0, 20.0 -10.0) 200
>>> # Extracting orientations from map >>> orientations = gg.vector.extract_orientations_from_map(gdf=gdf) >>> orientations geometry azimuth dip X Y polarity 0 POINT (10.0 -10.0) 135.00 74.21 10.00 -10.00 1 1 POINT (10.0 -5.0) 116.57 83.62 10.00 -5.00 1
See also
calculate_azimuth
Calculating the azimuth for orientations on a map
create_linestring_from_points
Create LineString from points
create_linestring_gdf
Create GeoDataFrame with LineStrings from points
calculate_distance_linestrings
Calculating the distance between LineStrings
calculate_orientations_from_strike_lines
Calculating the orientations from strike lines
- gemgis.vector.extract_xy(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True, overwrite_xy: bool = True, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None, remove_total_bounds: bool = False, threshold_bounds: Union[float, int] = 0.1) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings, Polygons, Geometry Collections) and returning a GeoDataFrame with X and Y coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data such as Shapely Points, LineStrings, MultiLineStrings or Polygons or data loaded from disc with GeoPandas (i.e. Shape File)
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
overwrite_xy (bool) – Variable to overwrite existing X and Y values. Options include:
True
orFalse
, default set toFalse
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
remove_total_bounds (bool) – Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons Options include:
True
orFalse
, default set toFalse
threshold_bounds (Union[float, int]) – Variable to set the distance to the total bound from where vertices are being removed, e.g.
threshold_bounds=10
, default set to0.1
- Returns
gdf – GeoDataFrame with appended x, y columns and Point geometry features
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Changed in version 1.1: If a GeoDataFrame contains LineStrings and MultiLineStrings, the index of the exploded GeoDataFrame will now be reset. Not resetting the index will cause index errors later on.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Extracting X and Y Coordinates from Shapely Base Geometries >>> gdf_xy = gg.vector.extract_xy(gdf=gdf, reset_index=False) >>> gdf_xy formation geometry X Y 0 Ton POINT (19.150 293.313) 19.15 293.31 1 Ton POINT (61.934 381.459) 61.93 381.46 2 Ton POINT (109.358 480.946) 109.36 480.95 3 Ton POINT (157.812 615.999) 157.81 616.00 4 Ton POINT (191.318 719.094) 191.32 719.09
See also
extract_xy_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points
extract_xy_linestring
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings and saving the X and Y coordinates as lists for each LineString
extract_xy_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings
Note
GeoDataFrames that contain multiple types of geometries are currently not supported. Please use
gdf = gdf.explode().reset_index(drop=True)
to create a GeoDataFrame with only one type of geometries
- gemgis.vector.extract_xy_from_polygon_intersections(gdf: geopandas.geodataframe.GeoDataFrame, extract_coordinates: bool = False, drop_index: bool = True) geopandas.geodataframe.GeoDataFrame #
Calculating the intersections between Polygons; the table must be sorted by stratigraphic age
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Polygons of a geological map ordered by their stratigraphic age
extract_coordinates (bool) – Variable to extract X and Y coordinates from resulting Shapely Objects. Options include:
True
orFalse
, default set toFalse
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
- Returns
intersections – GeoDataFrame containing the intersections of the polygons of a geological map
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> import geopandas as gpd >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating second Polygon >>> polygon2 = Polygon([[10, 0], [20, 0], [20, 10], [10, 10], [10, 0]]) >>> polygon2.wkt 'POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))'
>>> # Creating GeoDataFrame from polygons and adding formation names >>> gdf = gpd.GeoDataFrame(geometry=[polygon1, polygon2]) >>> gdf['formation'] = ['Formation1', 'Formation2'] >>> gdf geometry formation 0 POLYGON (((0 0, 10 0, 10 10, 0 10, 0 0)) Formation1 1 POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0)) Formation2
>>> # Extracting X an Y coordinates from polygon intersections >>> intersection = gg.vector.extract_xy_from_polygon_intersections(gdf=gdf) >>> intersection formation geometry 0 Formation1 LINESTRING (10.0 0.0, 10.0 10.0)
See also
intersection_polygon_polygon
Intersecting a polygon with a polygon
intersections_polygon_polygons
Intersecting a polygons with multiple polygons
intersections_polygons_polygons
Intersecting multiple polygons with multiple polygons
- gemgis.vector.extract_xy_linestring(gdf: geopandas.geodataframe.GeoDataFrame, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None) geopandas.geodataframe.GeoDataFrame #
Extracting the coordinates of Shapely LineStrings within a GeoDataFrame and storing the X and Y coordinates in lists per LineString
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type LineString
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (Optional[Sequence[float]]) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
- Returns
gdf – GeoDataFrame containing the additional X and Y columns with lists of X and Y coordinates
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Sand1 LINESTRING (0.256 264.862, 10.593 276.734, 17.... 1 None Ton LINESTRING (0.188 495.787, 8.841 504.142, 41.0... 2 None Ton LINESTRING (970.677 833.053, 959.372 800.023, ...
>>> # Extracting X and Y Coordinates from LineString Objects >>> gdf_xy = gg.vector.extract_xy_linestring(gdf=gdf) >>> gdf_xy id formation geometry X Y 0 None Sand1 LINESTRING (0.256 264.862, 10.593 276.734, 17.... [0.256327195431048, 10.59346813871597, 17.1349... [264.86214748436396, 276.73370778641777, 289.0... 1 None Ton LINESTRING (0.188 495.787, 8.841 504.142, 41.0... [0.1881868620686138, 8.840672956663411, 41.092... [495.787213546976, 504.1418419288791, 546.4230... 2 None Ton LINESTRING (970.677 833.053, 959.372 800.023, ... [970.6766251230017, 959.3724321757514, 941.291... [833.052616499831, 800.0232029873156, 754.8012...
See also
extract_xy_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings
extract_xy_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points
extract_xy
Extracting X and Y coordinates from Vector Data
- gemgis.vector.extract_xy_linestrings(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_id: bool = True, drop_index: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True, overwrite_xy: bool = False, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (LineStrings) and returning a GeoDataFrame with X and Y coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type LineString
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
overwrite_xy (bool) – Variable to overwrite existing X and Y values. Options include:
True
orFalse
, default set toFalse
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (Optional[Sequence[float]]) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
- Returns
gdf – GeoDataFrame with appended X and Y coordinates as additional columns and optional columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Sand1 LINESTRING (0.256 264.862, 10.593 276.734, 17.... 1 None Ton LINESTRING (0.188 495.787, 8.841 504.142, 41.0... 2 None Ton LINESTRING (970.677 833.053, 959.372 800.023, ...
>>> # Extracting X and Y Coordinates from LineString Objects >>> gdf_xy = gg.vector.extract_xy_linestrings(gdf=gdf, reset_index=False) >>> gdf_xy formation geometry X Y 0 Sand1 POINT (0.256 264.862) 0.26 264.86 1 Sand1 POINT (10.593 276.734) 10.59 276.73 2 Sand1 POINT (17.135 289.090) 17.13 289.09 3 Sand1 POINT (19.150 293.313) 19.15 293.31 4 Sand1 POINT (27.795 310.572) 27.80 310.57
See also
extract_xy_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points
extract_xy_linestring
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings and saving the X and Y coordinates as lists for each LineString
extract_xy
Extracting X and Y coordinates from Vector Data
Note
The function was adapted to also extract Z coordinates from LineStrings
- gemgis.vector.extract_xy_points(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_id: bool = True, drop_index: bool = True, overwrite_xy: bool = False, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points) and returning a GeoDataFrame with X and Y coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type Point
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
overwrite_xy (bool) – Variable to overwrite existing X and Y values. Options include:
True
orFalse
, default set toFalse
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
- Returns
gdf – GeoDataFrame with appended X and Y coordinates as new columns and optional columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Extracting X and Y Coordinates from Point Objects >>> gdf_xy = gg.vector.extract_xy_points(gdf=gdf, reset_index=False) >>> gdf_xy formation geometry X Y 0 Ton POINT (19.150 293.313) 19.15 293.31 1 Ton POINT (61.934 381.459) 61.93 381.46 2 Ton POINT (109.358 480.946) 109.36 480.95 3 Ton POINT (157.812 615.999) 157.81 616.00 4 Ton POINT (191.318 719.094) 191.32 719.09
See also
extract_xy_linestring
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings and saving the X and Y coordinates as lists for each LineString
extract_xy_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings
extract_xy
Extracting X and Y coordinates from Vector Data
- gemgis.vector.extract_xyz(gdf: geopandas.geodataframe.GeoDataFrame, dem: Union[numpy.ndarray, rasterio.io.DatasetReader] = None, minz: float = None, maxz: float = None, extent: List[Union[int, float]] = None, reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True, target_crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None, bbox: Optional[Sequence[float]] = None, remove_total_bounds: bool = False, threshold_bounds: Union[float, int] = 0.1) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings Polygons) and Z values from a NumPy nd.array or a Rasterio object and returning a GeoDataFrame with X, Y, and Z coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing Shapely Points, LineStrings, MultiLineStrings or Polygons
dem (Union[np.ndarray, rasterio.io.DatasetReader]) – NumPy ndarray or Rasterio object containing the height values, default value is None in case geometries contain Z values
minz (float) – Value defining the minimum elevation of the data that needs to be returned, e.g.
minz=50
, defaultNone
maxz (float) – Value defining the maximum elevation of the data that needs to be returned, e.g.
maxz=500
, defaultNone
extent (List[Union[float,int]]) – List containing the extent of the np.ndarray, must be provided in the same CRS as the gdf, e.g.
extent=[0, 972, 0, 1069]
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
target_crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
remove_total_bounds (bool) – Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons Options include:
True
orFalse
, default set toFalse
threshold_bounds (Union[float, int]) – Variable to set the distance to the total bound from where vertices are being removed, e.g.
threshold_bounds=10
, default set to0.1
- Returns
gdf – GeoDataFrame containing the X, Y, and Z coordinates as additional columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> import rasterio >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Loading raster file >>> dem = rasterio.open(fp='dem.tif') >>> dem <open DatasetReader name='dem.tif' mode='r'>
>>> # Extracting X, Y, and Z Coordinates from Shapely Base Geometries and DEM >>> gdf_xyz = gg.vector.extract_xyz(gdf=gdf, dem=dem, reset_index=reset_index) >>> gdf_xyz formation geometry X Y Z 0 Ton POINT (19.150 293.313) 19.15 293.31 364.99 1 Ton POINT (61.934 381.459) 61.93 381.46 400.34 2 Ton POINT (109.358 480.946) 109.36 480.95 459.55 3 Ton POINT (157.812 615.999) 157.81 616.00 525.69 4 Ton POINT (191.318 719.094) 191.32 719.09 597.63
See also
extract_xyz_array
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model as array
extract_xyz_rasterio
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation as rasterio object
- gemgis.vector.extract_xyz_array(gdf: geopandas.geodataframe.GeoDataFrame, dem: numpy.ndarray, extent: List[float], minz: float = None, maxz: float = None, reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None, remove_total_bounds: bool = False, threshold_bounds: Union[float, int] = 0.1) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings Polygons) and Z values from a NumPy nd.array and returning a GeoDataFrame with X, Y, and Z coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing Shapely Points, LineStrings, MultiLineStrings or Polygons
dem (np.ndarray) – NumPy ndarray containing the height values
extent (list) – List containing the extent of the np.ndarray, must be provided in the same CRS as the gdf, e.g.
extent=[0, 972, 0, 1069]
minz (float) – Value defining the minimum elevation the data needs to be returned, e.g.
minz=50
, defaultNone
maxz (float) – Value defining the maximum elevation the data needs to be returned, e.g.
maxz=500
, defaultNone
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
remove_total_bounds (bool) – Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons Options include:
True
orFalse
, default set toFalse
threshold_bounds (Union[float, int]) – Variable to set the distance to the total bound from where vertices are being removed, e.g.
threshold_bounds=10
, default set to0.1
- Returns
gdf – GeoDataFrame containing the X, Y, and Z coordinates
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> import rasterio >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Loading raster file >>> dem = rasterio.open(fp='dem.tif') >>> dem <open DatasetReader name='dem.tif' mode='r'>
>>> # Defining the extent of the array >>> extent = [0, 972, 0, 1069]
>>> # Extracting X, Y, and Z Coordinates from Shapely Base Geometries and array >>> gdf_xyz = gg.vector.extract_xyz_array(gdf=gdf, dem=dem.read(1), extent=extent, reset_index=reset_index) >>> gdf_xyz formation geometry X Y Z 0 Ton POINT (19.150 293.313) 19.15 293.31 364.99 1 Ton POINT (61.934 381.459) 61.93 381.46 400.34 2 Ton POINT (109.358 480.946) 109.36 480.95 459.55 3 Ton POINT (157.812 615.999) 157.81 616.00 525.69 4 Ton POINT (191.318 719.094) 191.32 719.09 597.63
See also
extract_xyz_rasterio
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model as rasterio object
extract_xyz
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model
- gemgis.vector.extract_xyz_from_cross_sections(profile_gdf: geopandas.geodataframe.GeoDataFrame, interfaces_gdf: geopandas.geodataframe.GeoDataFrame, profile_name_column: str = 'name') geopandas.geodataframe.GeoDataFrame #
Extracting X, Y, and Z coordinates from cross sections and digitized interfaces
- Parameters
profile_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the traces (LineStrings) of cross sections on a map and a profile name
interfaces_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the LineStrings of digitized interfaces, associated formation and the profile name
profile_name_column (str) – Name of the profile column, default is
profile_name_column='name'
- Returns
gdf – GeoDataFrame containing the X, Y, and Z information of all extracted digitized interfaces on cross sections
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> import geopandas as gpd >>> linestring = LineString([(0, 0), (20, -20)]) >>> linestring.wkt 'LINESTRING (0 0, 20 -20)'
>>> # Creating GeoDataFrame from LineString and ad Profile names >>> profile_gdf = gpd.GeoDataFrame(geometry=[linestring, linestring]) >>> profile_gdf['name'] = ['Profile1', 'Profile2'] >>> profile_gdf geometry name 0 LINESTRING (0.0 0.0, 20.0 -20.0) Profile1 1 LINESTRING (0.0 0.0, 20.0 -20.0) Profile2
>>> # Creating second LineString >>> interfaces = LineString([(2, -2), (5, -5)]) >>> interfaces.wkt 'LINESTRING (2 -2, 5 -5)'
>>> # Creating GeoDataFrame from LineString and ad Profile names >>> gdf = gpd.GeoDataFrame(geometry=[interfaces, interfaces]) >>> gdf['name'] = ['Profile1', 'Profile2'] >>> gdf geometry name 0 LINESTRING (2.0 -2.0, 5.0 -5.0) Profile1 1 LINESTRING (2.0 -2.0, 5.0 -5.0) Profile2
>>> # Extracting X, Y, and Z coordinates from cross sections >>> gdf_points = gg.vector.extract_xyz_from_cross_sections(profile_gdf=profile_gdf, interfaces_gdf=gdf) >>> gdf_points name geometry X Y Z 0 Profile1 POINT (1.41421 -1.41421) 1.41 -1.41 -2.00 1 Profile1 POINT (3.53553 -3.53553) 3.54 -3.54 -5.00 2 Profile2 POINT (1.41421 -1.41421) 1.41 -1.41 -2.00 3 Profile2 POINT (3.53553 -3.53553) 3.54 -3.54 -5.00
See also
calculate_coordinates_for_point_on_cross_section
Calculating the coordinates for a Point on a cross section
calculate_coordinates_for_linestring_on_cross_sections
Calculating the coordinates for one LineString on cross sections
calculate_coordinates_for_linestrings_on_cross_sections
Calculating the coordinates for LineStrings on cross sections
extract_interfaces_coordinates_from_cross_section
Extracting the coordinates of interfaces from cross sections
- gemgis.vector.extract_xyz_linestrings(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_index: bool = True) geopandas.geodataframe.GeoDataFrame #
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely LineStrings with Z components
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Shapely LineStrings with X, Y, and Z components
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing Shapely Points with appended X, Y, and Z columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Shapely LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> import geopandas as gpd >>> linestring = LineString(([1,2,3], [4,5,6])) >>> linestring.wkt 'LINESTRING Z (1 2 3, 4 5 6)'
>>> # Creating GeoDataFrame from LineString >>> gdf = gpd.GeoDataFrame(geometry=[linestring, linestring]) >>> gdf geometry 0 LINESTRING Z (1.00000 2.00000 3.00000, 4.00000... 1 LINESTRING Z (1.00000 2.00000 3.00000, 4.00000...
>>> # Extracting X, Y, and Z Coordinates from Point Objects >>> gdf = gg.vector.extract_xyz_linestrings(gdf=gdf) >>> gdf geometry points X Y Z 0 POINT (1.00000 2.00000) (1.0, 2.0, 3.0) 1.00 2.00 3.00 1 POINT (4.00000 5.00000) (4.0, 5.0, 6.0) 4.00 5.00 6.00 2 POINT (1.00000 2.00000) (1.0, 2.0, 3.0) 1.00 2.00 3.00 3 POINT (4.00000 5.00000) (4.0, 5.0, 6.0) 4.00 5.00 6.00
See also
extract_xyz_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points with Z components
extract_xyz_polygons
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Polygons with Z component
- gemgis.vector.extract_xyz_points(gdf: geopandas.geodataframe.GeoDataFrame) geopandas.geodataframe.GeoDataFrame #
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely Points with Z components
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Shapely Points with X, Y, and Z components
- Returns
gdf – GeoDataFrame containing Shapely Points with appended X, Y, and Z columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Shapely Point >>> import gemgis as gg >>> from shapely.geometry import Point >>> import geopandas as gpd >>> point = Point(1,2,4) >>> point.wkt 'POINT Z (0 0 0)'
>>> # Creating GeoDataFrame from Point >>> gdf = gpd.GeoDataFrame(geometry=[point, point]) >>> gdf geometry 0 POINT Z (0.00000 0.00000 0.00000) 1 POINT Z (0.00000 0.00000 0.00000)
>>> # Extracting X, Y, and Z Coordinates from Point Objects >>> gdf = gg.vector.extract_xyz_points(gdf=gdf) >>> gdf geometry X Y Z 0 POINT Z (1.00000 2.00000 3.00000) 1.00 2.00 3.00 1 POINT Z (1.00000 2.00000 3.00000) 1.00 2.00 3.00
See also
extract_xyz_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings with Z components
extract_xyz_polygons
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Polygons with Z component
- gemgis.vector.extract_xyz_polygons(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_index: bool = True) geopandas.geodataframe.GeoDataFrame #
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely Polygons with Z components
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing Shapely Polygons with X, Y, and Z components
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
- Returns
gdf – GeoDataFrame containing Shapely Points with appended X, Y, and Z columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Shapely Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> import geopandas as gpd >>> polygon = Polygon([[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1], [0, 0, 1]]) >>> polygon.wkt 'POLYGON Z ((0 0 1, 1 0 1, 1 1 1, 0 1 1, 0 0 1))'
>>> # Creating GeoDataFrame from LineString >>> gdf = gpd.GeoDataFrame(geometry=[polygon, polygon]) >>> gdf geometry 0 POLYGON Z ((0.00000 0.00000 1.00000, 1.00000 0... 1 POLYGON Z ((0.00000 0.00000 1.00000, 1.00000 0...
>>> # Extracting X, Y, and Z Coordinates from Point Objects >>> gdf = gg.vector.extract_xyz_polygons(gdf=gdf) >>> gdf geometry points X Y Z 0 POINT (0.00000 0.00000) [0.0, 0.0, 1.0] 0.00 0.00 1.00 1 POINT (1.00000 0.00000) [1.0, 0.0, 1.0] 1.00 0.00 1.00 2 POINT (1.00000 1.00000) [1.0, 1.0, 1.0] 1.00 1.00 1.00 3 POINT (0.00000 1.00000) [0.0, 1.0, 1.0] 0.00 1.00 1.00
See also
extract_xyz_points
Extracting X and Y coordinates from a GeoDataFrame containing Shapely Points with Z component
extract_xyz_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings with Z components
- gemgis.vector.extract_xyz_rasterio(gdf: geopandas.geodataframe.GeoDataFrame, dem: rasterio.io.DatasetReader, minz: float = None, maxz: float = None, reset_index: bool = True, drop_index: bool = True, drop_id: bool = True, drop_points: bool = True, drop_level0: bool = True, drop_level1: bool = True, target_crs: Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS] = None, bbox: Optional[Sequence[float]] = None, remove_total_bounds: bool = False, threshold_bounds: Union[float, int] = 0.1) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points, LineStrings, MultiLineStrings Polygons) and z values from a rasterio object and returning a GeoDataFrame with X, Y, and Z coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing Shapely Points, LineStrings, MultiLineStrings or Polygons
dem (rasterio.io.DatasetReader) – Rasterio object containing the height values
minz (float) – Value defining the minimum elevation the data needs to be returned, e.g.
minz=50
, defaultNone
maxz (float) – Value defining the maximum elevation the data needs to be returned, e.g.
maxz=500
, defaultNone
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame, default
True
drop_level0 (bool) – Variable to drop the level_0 column. Options include:
True
orFalse
, default set toTrue
drop_level1 (bool) – Variable to drop the level_1 column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_points (bool) – Variable to drop the points column. Options include:
True
orFalse
, default set toTrue
target_crs (Union[str, pyproj.crs.crs.CRS, rasterio.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
remove_total_bounds (bool) – Variable to remove the vertices representing the total bounds of a GeoDataFrame consisting of Polygons Options include:
True
orFalse
, default set toFalse
threshold_bounds (Union[float, int]) – Variable to set the distance to the total bound from where vertices are being removed, e.g.
threshold_bounds=10
, default set to0.1
- Returns
gdf – GeoDataFrame containing the X, Y, and Z coordinates
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> import rasterio >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Loading raster file >>> dem = rasterio.open(fp='dem.tif') >>> dem <open DatasetReader name='dem.tif' mode='r'>
>>> # Extracting X, Y, and Z Coordinates from Shapely Base Geometries and raster >>> gdf_xyz = gg.vector.extract_xyz_rasterio(gdf=gdf, dem=dem, reset_index=reset_index) >>> gdf_xyz formation geometry X Y Z 0 Ton POINT (19.150 293.313) 19.15 293.31 364.99 1 Ton POINT (61.934 381.459) 61.93 381.46 400.34 2 Ton POINT (109.358 480.946) 109.36 480.95 459.55 3 Ton POINT (157.812 615.999) 157.81 616.00 525.69 4 Ton POINT (191.318 719.094) 191.32 719.09 597.63
See also
extract_xyz_array
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model as array
extract_xyz
Extracting X, Y, and Z coordinates from a GeoDataFrame and Digital Elevation Model
- gemgis.vector.interpolate_raster(gdf: geopandas.geodataframe.GeoDataFrame, value: str = 'Z', method: str = 'nearest', n: int = None, res: int = 1, extent: List[Union[int, float]] = None, seed: int = None, **kwargs) numpy.ndarray #
Interpolating a raster/digital elevation model from point or line Shape file
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing vector data of geom_type Point or Line containing the Z values of an area
value (str) – Value to be interpolated, e.g.
value='Z'
, default is'Z'
method (string) – Method used to interpolate the raster. Options include:
'nearest', 'linear', 'cubic', 'rbf'
res (int) – Resolution of the raster in X and Y direction, e.g.
res=50
seed (int) – Seed for the drawing of random numbers, e.g.
seed=1
n (int) – Number of samples used for the interpolation, e.g.
n=100
extent (List[Union[float, int]]) – Values for minx, maxx, miny and maxy values to define the boundaries of the raster, e.g.
extent=[0, 972, 0, 1069]
**kwargs (optional keyword arguments) – For kwargs for rbf and griddata see: https://docs.scipy.org/doc/scipy/reference/interpolate.html
- Returns
array – Array representing the interpolated raster/digital elevation model
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id Z geometry 0 None 400 LINESTRING (0.741 475.441, 35.629 429.247, 77.... 1 None 300 LINESTRING (645.965 0.525, 685.141 61.866, 724... 2 None 400 LINESTRING (490.292 0.525, 505.756 40.732, 519... 3 None 600 LINESTRING (911.433 1068.585, 908.856 1026.831... 4 None 700 LINESTRING (228.432 1068.585, 239.772 1017.037...
>>> # Interpolating vector data >>> raster = gg.vector.interpolate_raster(gdf=gdf, method='rbf') >>> raster[:2] array([[393.56371914, 393.50838517, 393.45386851, ..., 396.15856133, 398.11421775, 400.06334288], [393.41982945, 393.36494645, 393.31088433, ..., 396.20694282, 398.16690286, 400.12027997]])
- gemgis.vector.intersection_polygon_polygon(polygon1: shapely.geometry.polygon.Polygon, polygon2: shapely.geometry.polygon.Polygon) Union[shapely.geometry.linestring.LineString, shapely.geometry.polygon.Polygon] #
Calculating the intersection between to Shapely Polygons
- Parameters
polygon1 (shapely.geometry.polygon.Polygon) – First polygon used for intersecting, e.g.
polygon1=Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
polygon2 (shapely.geometry.polygon.Polygon) – Second polygon used for intersecting, e.g.
polygon2=Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
- Returns
intersection – Intersected geometry as Shapely Object
- Return type
Union[shapely.geometry.linestring.LineString, shapely.geometry.polygon.Polygon]
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating second Polygon >>> polygon2 = Polygon([[10, 0], [20, 0], [20, 10], [10, 10], [10, 0]]) >>> polygon2.wkt 'POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))'
>>> # Calculating the intersection between two polygons >>> intersection = gg.vector.intersection_polygon_polygon(polygon1=polygon1, polygon2=polygon2) >>> intersection.wkt 'LINESTRING (10 0, 10 10)'
See also
intersections_polygon_polygons
Intersecting a polygon with mutiple polygons
intersections_polygons_polygons
Intersecting multiple polygons with multiple polygons
extract_xy_from_polygon_intersections
Extracting intersections between multiple polygons
- gemgis.vector.intersections_polygon_polygons(polygon1: shapely.geometry.polygon.Polygon, polygons2: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) List[shapely.geometry.base.BaseGeometry] #
Calculating the intersections between one polygon and a list of polygons
- Parameters
polygon1 (shapely.geometry.polygon.Polygon) – First polygon used for intersecting, e.g.
polygon1=Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
polygons2 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of polygons as list or GeoDataFrame to get intersected
- Returns
intersections – List of intersected geometries
- Return type
List[shapely.geometry.base.BaseGeometry]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating second Polygon >>> polygon2 = Polygon([[10, 0], [20, 0], [20, 10], [10, 10], [10, 0]]) >>> polygon2.wkt 'POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))'
>>> # Creating list of polygons >>> polygons2 = [polygon2, polygon2]
>>> # Calculating the intersections between a polygon with polygons >>> intersection = gg.vector.intersections_polygon_polygons(polygon1=polygon1, polygons2=polygons2) >>> intersection [<shapely.geometry.linestring.LineString at 0x231eaf22100>, <shapely.geometry.linestring.LineString at 0x231eab22970>]
>>> # Inspecting the first element of the list >>> intersection[0].wkt 'LINESTRING (10 0, 10 10)'
>>> # Creating the second element of the list >>> intersection[1].wkt 'LINESTRING (10 0, 10 10)'
See also
intersection_polygon_polygon
Intersecting a polygon with a polygon
intersections_polygons_polygons
Intersecting multiple polygons with multiple polygons
extract_xy_from_polygon_intersections
Extracting intersections between multiple polygons
- gemgis.vector.intersections_polygons_polygons(polygons1: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]], polygons2: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) List[shapely.geometry.base.BaseGeometry] #
Calculating the intersections between a list of Polygons
- Parameters
polygons1 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of Polygons or GeoDataFrame containing Polygons to be intersected
polygons2 (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.polygon.Polygon]]) – List of Polygons or GeoDataFrame containing Polygons to be intersected
- Returns
intersections – List of intersected geometries
- Return type
List[shapely.geometry.base.BaseGeometry]
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating list of polygons >>> polygons1 = [polygon1, polygon1]
>>> # Creating second polygon >>> polygon2 = Polygon([[10, 0], [20, 0], [20, 10], [10, 10], [10, 0]]) >>> polygon2.wkt 'POLYGON ((10 0, 20 0, 20 10, 10 10, 10 0))'
>>> # Creating list of polygons >>> polygons2 = [polygon2, polygon2]
>>> # Calculating intersections between polygons and polygons >>> intersection = gg.vector.intersections_polygons_polygons(polygons1=polygons1, polygons2=polygons2) >>> intersection [<shapely.geometry.linestring.LineString at 0x231eaf4dd90>, <shapely.geometry.linestring.LineString at 0x231ec6e8df0>, <shapely.geometry.linestring.LineString at 0x231eaf4dc70>, <shapely.geometry.linestring.LineString at 0x231eaf4dd00>]
>>> # Inspecting the first element of the list >>> intersection[0].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the second element of the list >>> intersection[1].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the third element of the list >>> intersection[2].wkt 'LINESTRING (10 0, 10 10)'
>>> # Inspecting the fourth element of the list >>> intersection[3].wkt 'LINESTRING (10 0, 10 10)'
See also
intersection_polygon_polygon
Intersecting a polygon with a polygon
intersections_polygon_polygons
Intersecting a polygons with multiple polygons
extract_xy_from_polygon_intersections
Extracting intersections between multiple polygons
- gemgis.vector.load_gpx(path: str, layer: Union[int, str] = 'tracks') Collection #
Loading a GPX file as collection
- Parameters
path (str) – Path to the GPX file, e.g.
path='file.gpx'
layer (Union[int, str]) – The integer index or name of a layer in a multi-layer dataset, e.g.
layer='tracks'
, default istracks
- Returns
gpx – Collection containing the GPX data
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> gpx = gg.vector.load_gpx(path='file.gpx', layer='tracks') >>> gpx <open Collection 'file.gpx:tracks', mode 'r' at 0x24f1c90ffa0>
See also
load_gpx_as_dict
Loading a GPX file as dict
load_gpx_as_geometry
Loading a GPX file as Shapely BaseGeometry
- gemgis.vector.load_gpx_as_dict(path: str, layer: Union[int, str] = 'tracks') Collection #
Loading a GPX file as dict
- Parameters
path (str) – Path to the GPX file, e.g.
path='file.gpx'
layer (Union[int, str]) – The integer index or name of a layer in a multi-layer dataset, e.g.
layer='tracks'
, default istracks
- Returns
gpx_dict – Dict containing the GPX data
- Return type
dict
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> gpx = gg.vector.load_gpx_as_dict(path='file.gpx', layer='tracks') >>> gpx {'type': 'Feature', 'id': '0', 'properties': OrderedDict([('name', 'First half marathon distance of the year'), ('cmt', None), ('desc', None), ('src', None), ('link1_href', None), ('link1_text', None), ('link1_type', None), ('link2_href', None), ('link2_text', None), ('link2_type', None), ('number', None), ('type', '9')]), 'geometry': {'type': 'MultiLineString', 'coordinates': [[(8.496285, 52.705566), (8.49627, 52.705593), (8.496234, 52.705629),...]]}}
See also
load_gpx_as
Loading a GPX file as Collection
load_gpx_as_geometry
Loading a GPX file as Shapely BaseGeometry
- gemgis.vector.load_gpx_as_geometry(path: str, layer: Union[int, str] = 'tracks') shapely.geometry.base.BaseGeometry #
Loading a GPX file as Shapely Geometry
- Parameters
path (str) – Path to the GPX file, e.g.
path='file.gpx'
layer (Union[int, str]) – The integer index or name of a layer in a multi-layer dataset, e.g.
layer='tracks'
, default istracks
- Returns
shape – Shapely BaseGeometry containing the geometry data of the GPX file
- Return type
shapely.geometry.base.BaseGeometry
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> gpx = gg.vector.load_gpx_as_geometry(path='file.gpx', layer='tracks') >>> gpx.wkt 'MULTILINESTRING ((8.496285 52.705566, 8.496270000000001 52.705593, 8.496233999999999 52.705629, 8.496205 52.705664, 8.496181 52.705705, 8.496171 52.705754,...)
See also
load_gpx
Loading a GPX file as Collection
load_gpx_as_dict
Loading a GPX file as dict
- gemgis.vector.remove_interfaces_within_fault_buffers(fault_gdf: geopandas.geodataframe.GeoDataFrame, interfaces_gdf: geopandas.geodataframe.GeoDataFrame, distance: Union[int, float] = None, remove_empty_geometries: bool = True, extract_coordinates: bool = True) Tuple[geopandas.geodataframe.GeoDataFrame, geopandas.geodataframe.GeoDataFrame] #
Function to create a buffer around a GeoDataFrame containing fault data and removing interface points that are located within this buffer
- Parameters
fault_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the fault data
interfaces_gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the interface point data
distance (float, int) – Distance of the buffer around the geometry object, e.g.
distance=10
remove_empty_geometries (bool) – Variable to remove empty geometries, Options include:
True
orFalse
defaultTrue
extract_coordinates (bool) – Variable to extract X and Y coordinates from resulting Shapely Objects, Options include:
True
orFalse
defaultTrue
- Returns
gdf_out (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the vertices located outside the fault buffer
gdf_in (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the vertices located inside the fault buffer
New in version 1.0.x.
Example
>>> # Loading Libraries >>> import gemgis as gg >>> import geopandas as gpd >>> from shapely.geometry import Point, LineString
>>> # Creating first Point >>> point1 = Point(0, 0) >>> point1.wkt 'POINT (0 0)'
>>> # Creating second Point >>> point2 = Point(5, 0) >>> point2.wkt 'POINT (5 0)'
>>> # Creating GeoDataFrame from Points >>> fault_gdf = gpd.GeoDataFrame(geometry=[point1, point2])
>>> # Creating first LineString >>> linestring1 = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring1.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Creating second LineString >>> linestring2 = LineString([(10, 0), (20, 10), (30, 20)]) >>> linestring2.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Creating GeoDataFrame from LineStrings >>> buffer_objects_gdf = gpd.GeoDataFrame(geometry=[linestring1, linestring2])
>>> # Removing interfaces within fault buffers >>> result_out, result_in = gg.vector.remove_interfaces_within_fault_buffers(fault_gdf=fault_gdf, interfaces_gdf=buffer_objects_gdf, distance=10)
>>> # Inspecting the Base Geometries that remain outside >>> result_out geometry X Y 0 POINT (7.07107 7.07107) 7.07 7.07 1 POINT (10.00000 10.00000) 10.00 10.00 2 POINT (20.00000 20.00000) 20.00 20.00 3 POINT (10.00000 0.00000) 10.00 0.00 4 POINT (20.00000 10.00000) 20.00 10.00 5 POINT (30.00000 20.00000) 30.00 20.00
>>> # Inspecting the Base Geometries that remain inside >>> result_in geometry X Y 0 POINT (0.00000 0.00000) 0.00 0.00 1 POINT (7.07107 7.07107) 7.07 7.07
See also
remove_object_within_buffer
Removing one object from one buffered object
remove_objects_within_buffer
Removing several objects from one buffered object
- gemgis.vector.remove_object_within_buffer(buffer_object: shapely.geometry.base.BaseGeometry, buffered_object: shapely.geometry.base.BaseGeometry, distance: Union[int, float] = None, buffer: bool = True) Tuple[shapely.geometry.base.BaseGeometry, shapely.geometry.base.BaseGeometry] #
Removing object from a buffered object by providing a distance
- Parameters
buffer_object (shapely.geometry.base.BaseGeometry) – Shapely object for which a buffer will be created, e.g.
buffer_object=Point(0, 0)
buffered_object (shapely.geometry.base.BaseGeometry) – Shapely object that will be removed from the buffer, e.g.
buffered_object=LineString([(0, 0), (10, 10), (20, 20)])
distance (Union[float, int]) – Distance of the buffer around the geometry object, e.g.
distance=10
, default isNone
buffer (bool) – Variable to create a buffer. Options include:
True
orFalse
, default set toTrue
- Returns
result_out (shapely.geometry.base.BaseGeometry) – Shapely object that remains after the buffering (outside the buffer)
result_in (shapely.geometry.base.BaseGeometry) – Shapely object that was buffered (inside the buffer)
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Point >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> point = Point(0, 0) >>> point.wkt 'POINT (0 0)'
>>> # Creating LineString >>> linestring = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Removing object within buffer >>> result_out, result_in = gg.vector.remove_object_within_buffer(buffer_object=point, buffered_object=linestring, distance=10)
>>> # Inspecting the Base Geometry that remains outside >>> result_out.wkt 'LINESTRING (7.071067811865473 7.071067811865473, 10 10, 20 20)'
>>> # Inspecting the Base Geometry that remains inside >>> result_in.wkt 'LINESTRING (0 0, 7.071067811865473 7.071067811865473)'
See also
remove_objects_within_buffer
Removing several objects from one buffered object
remove_interfaces_within_fault_buffers
Removing interfaces of layer boundaries within fault line buffers
- gemgis.vector.remove_objects_within_buffer(buffer_object: shapely.geometry.base.BaseGeometry, buffered_objects_gdf: Union[geopandas.geodataframe.GeoDataFrame, List[shapely.geometry.base.BaseGeometry]], distance: Union[int, float] = None, return_gdfs: bool = False, remove_empty_geometries: bool = False, extract_coordinates: bool = False, buffer: bool = True) Tuple[Union[List[shapely.geometry.base.BaseGeometry], geopandas.geodataframe.GeoDataFrame], Union[List[shapely.geometry.base.BaseGeometry], geopandas.geodataframe.GeoDataFrame]] #
Removing objects from a buffered object by providing a distance
- Parameters
buffer_object (shapely.geometry.base.BaseGeometry) – Shapely object for which a buffer will be created, e.g.
buffer_object=Point(0, 0)
buffered_object_gdf (Union[gpd.geodataframe.GeoDataFrame, List[shapely.geometry.base.BaseGeometry]]) – GeoDataFrame or List of Base Geometries containing Shapely objects that will be buffered by the buffer object
distance (float, int) – Distance of the buffer around the geometry object, e.g.
distance=10
return_gdfs (bool) – Variable to create GeoDataFrames of the created list of Shapely Objects. Options include:
True
orFalse
, default set toFalse
remove_empty_geometries (bool) – Variable to remove empty geometries. Options include:
True
orFalse
, default set toFalse
extract_coordinates (bool) – Variable to extract X and Y coordinates from resulting Shapely Objects. Options include:
True
orFalse
, default set toFalse
buffer (bool) – Variable to create a buffer. Options include:
True
orFalse
, default set toTrue
- Returns
result_out (list, gpd.geodataframe.GeoDataFrame) – List or GeoDataFrame of Shapely objects that remain after the buffering (outside the buffer)
result_in (list, gpd.geodataframe.GeoDataFrame) – List or GeoDataFrame of Shapely objects that was buffered (inside the buffer)
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Point >>> import gemgis as gg >>> from shapely.geometry import Point, LineString >>> point = Point(0, 0) >>> point.wkt 'POINT (0 0)'
>>> # Creating first LineString >>> linestring1 = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring1.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Creating second LineString >>> linestring2 = LineString([(10, 0), (20, 10), (30, 20)]) >>> linestring2.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Create list of buffer objects >>> buffer_objects = [linestring1, linestring2]
>>> # Removing objects within buffer >>> result_out, result_in = gg.vector.remove_objects_within_buffer(buffer_object=point, buffered_object_gdf=buffer_objects, distance=10)
>>> # Inspecting the Base Geometries that remain outside >>> result_out [<shapely.geometry.linestring.LineString at 0x2515421e4f0>, <shapely.geometry.linestring.LineString at 0x2515421e3d0>]
>>> # Inspecting the Base Geometries that remain inside >>> result_in [<shapely.geometry.linestring.LineString at 0x2515421e310>, <shapely.geometry.linestring.LineString at 0x2515421e6a0>]
See also
remove_object_within_buffer
Removing one object from one buffered object
remove_interfaces_within_fault_buffers
Removing interfaces of layer boundaries within fault line buffers
- gemgis.vector.set_dtype(gdf: geopandas.geodataframe.GeoDataFrame, dip: str = 'dip', azimuth: str = 'azimuth', formation: str = 'formation', polarity: str = 'polarity', x: str = 'X', y: str = 'Y', z: str = 'Z') geopandas.geodataframe.GeoDataFrame #
Checking and setting the dtypes of the input data GeoDataFrame
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the input vector data with uncorrected dtypes
dip (str) – Name of the column containing the dip data, e.g
dip='dip'
azimuth (str) – Name of the column containing the azimuth data, e.g
azimuth='azimuth'
formation (str) – Name of the column containing the formation data, e.g
formation='formation'
polarity (str) – Name of the column containing the polarity data, e.g
polarity='polarity'
x (str) – Name of the column containing the x coordinates, e.g
x='X'
y (str) – Name of the column containing the y coordinates, e.g
y='Y'
z (str) – Name of the column containing the z coordinates, e.g
z='Z'
- Returns
gdf – GeoDataFrame containing the input vector data with corrected dtypes
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp')
>>> # Setting the data types >>> gdf_dtypes = gg.vector.set_dtype(gdf=gdf)
- gemgis.vector.sort_by_stratigraphy(gdf: geopandas.geodataframe.GeoDataFrame, stratigraphy: List[str], formation_column: str = 'formation') geopandas.geodataframe.GeoDataFrame #
Sorting a GeoDataFrame by a provided list of Stratigraphic Units
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the unsorted input polygons
stratigraphy (List[str]) – List containing the stratigraphic units sorted by age, e.g.
stratigraphy=['Layer1' , 'Layer2']
formation_column (str) – Name of the formation column, default is formation, e.g.
formation_colum='formation'
- Returns
gdf_sorted – GeoDataFrame containing the sorted input polygons
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> import geopandas as gpd >>> polygon1 = Polygon([(0, 0), (1, 1), (1, 0)]) >>> polygon1.wkt 'POLYGON ((0 0, 1 1, 1 0, 0 0))'
>>> # Creating second polygon >>> polygon2 = Polygon([(0, 0), (2, 2), (2, 0)]) >>> polygon2.wkt 'POLYGON ((0 0, 2 2, 2 0, 0 0))'
>>> # Creating GeoDataFrame from polygons >>> gdf = gpd.GeoDataFrame(geometry=[polygon1, polygon2]) >>> gdf['formation'] = ['Layer2', 'Layer1'] >>> gdf geometry formation 0 POLYGON ((0.00000 0.00000, 1.00000 1.00000, 1.... Layer2 1 POLYGON ((10.00000 0.00000, 20.00000 0.00000, ... Layer1
>>> # Creating stratigraphy list >>> stratigraphy = ['Layer1' , 'Layer2']
>>> # Sorting GeoDataFrame by stratigraphy >>> gdf_sorted = gg.vector.sort_by_stratigraphy(gdf=gdf, stratigraphy=stratigraphy) >>> gdf_sorted geometry formation 0 POLYGON ((10.00000 0.00000, 20.00000 0.00000, ... Layer1 1 POLYGON ((0.00000 0.00000, 1.00000 1.00000, 1.... Layer2
- gemgis.vector.subtract_geom_objects(geom_object1: shapely.geometry.base.BaseGeometry, geom_object2: shapely.geometry.base.BaseGeometry) shapely.geometry.base.BaseGeometry #
Subtracting Shapely geometry objects from each other and returning the left over object
- Parameters
geom_object1 (shapely.geometry.base.BaseGeometry) – Shapely object from which other object will be subtracted, e.g.
geom_object1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]])
geom_object2 (shapely.geometry.base.BaseGeometry) – Shapely object which will be subtracted from other object e.g.
geom_object2 = Polygon([[5, 0], [15, 0], [15, 10], [5, 10], [5, 0]])
- Returns
result – Shapely object from which the second object was subtracted
- Return type
shapely.geometry.base.BaseGeometry
New in version 1.0.x.
Example
>>> # Loading Libraries and creating Polygon >>> import gemgis as gg >>> from shapely.geometry import Polygon >>> polygon1 = Polygon([[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]) >>> polygon1.wkt 'POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))'
>>> # Creating second Polygon >>> polygon2 = Polygon([[5, 0], [15, 0], [15, 10], [5, 10], [5, 0]]) >>> polygon2.wkt 'POLYGON ((5 0, 15 0, 15 10, 5 10, 5 0))'
>>> # Subtracting geometries from each other >>> difference = gg.vector.subtract_geom_objects(geom_object1=polygon1, geom_object2=polygon2) >>> difference.wkt 'POLYGON ((5 0, 0 0, 0 10, 5 10, 5 0))'
- gemgis.vector.unify_linestrings(linestrings: Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame], crs: Union[str, pyproj.crs.crs.CRS] = None, return_gdf: bool = True) Union[List[shapely.geometry.linestring.LineString], geopandas.geodataframe.GeoDataFrame] #
Unifying adjacent LineStrings to form LineStrings with multiple vertices
- Parameters
linestrings (Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]) – LineStrings consisting of two vertices representing extracted contour lines
crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
crs='EPSG:4647'
return_gdf (bool) – Variable to either return the data as GeoDataFrame or as list of LineStrings. Options include:
True
orFalse
, default set toTrue
- Returns
linestrings_merged – Merged Shapely LineStrings
- Return type
Union[List[shapely.geometry.linestring.LineString], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> linestrings = gpd.read_file(filename='file.shp') >>> linestrings geometry Z 0 LINESTRING Z (32409587.930 5780538.824 -2350.0... -2350.00 1 LINESTRING Z (32407304.336 5777048.086 -2050.0... -2050.00 2 LINESTRING Z (32408748.977 5778005.047 -2200.0... -2200.00 3 LINESTRING Z (32403693.547 5786613.994 -2400.0... -2400.00 4 LINESTRING Z (32404738.664 5782672.480 -2350.0... -2350.00
>>> # Merging linestrings >>> polygons_linestrings = gg.vector.unify_linestrings(linestrings=linestrings) >>> polygons_linestrings geometry 0 LINESTRING Z (32331825.641 5708789.973 -200.00... 1 LINESTRING Z (32334315.359 5723032.766 -250.00... 2 LINESTRING Z (32332516.312 5722028.768 -250.00... 3 LINESTRING Z (32332712.750 5721717.561 -250.00... 4 LINESTRING Z (32332516.312 5722028.768 -250.00...
- gemgis.vector.unify_polygons(polygons: Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame], crs: Union[str, pyproj.crs.crs.CRS] = None, return_gdf: bool = True) Union[List[shapely.geometry.polygon.Polygon], geopandas.geodataframe.GeoDataFrame] #
Unifying adjacent triangular polygons to form larger objects
- Parameters
polygons (Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]) – Triangular Shapely Polygons representing the faces of the mesh
crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
crs='EPSG:4647'
return_gdf (bool) – Variable to either return the data as GeoDataFrame or as list of LineStrings. Options include:
True
orFalse
, default set toTrue
- Returns
polygons_merged – Merged Shapely Polygons
- Return type
Union[List[shapely.geometry.polygon.Polygon], gpd.geodataframe.GeoDataFrame]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> polygons = gpd.read_file(filename='file.shp') >>> polygons geometry 0 POLYGON Z ((297077.414 5677487.262 -838.496, 2... 1 POLYGON Z ((298031.070 5678779.547 -648.688, 2... 2 POLYGON Z ((297437.539 5676992.094 -816.608, 2... 3 POLYGON Z ((298031.070 5678779.547 -648.688, 2... 4 POLYGON Z ((295827.680 5680951.574 -825.328, 2...
>>> # Merging polygons >>> polygons_merged = gg.vector.unify_polygons(polygons=polygons) >>> polygons_merged geometry 0 POLYGON Z ((396733.222 5714544.109 -186.252, 3... 1 POLYGON Z ((390252.635 5712409.037 -543.142, 3... 2 POLYGON Z ((391444.965 5710989.453 -516.000, 3... 3 POLYGON Z ((388410.007 5710903.900 -85.654, 38... 4 POLYGON Z ((384393.963 5714293.104 -614.106, 3...
gemgis.visualization module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.visualization.add_row_to_boreholes(df_groups: List[pandas.core.frame.DataFrame]) List[pandas.core.frame.DataFrame] #
Adding additional row to each borehole for further processing for 3D visualization
- Parameters
df_groups (List[pd.DataFrame]) – List of Pandas DataFrames containing the borehole data
- Returns
df_groups – List of Pandas DataFrames with additional row
- Return type
List[pd.DataFrame]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Adding row to DataFrames >>> grouped = df.groupby(['Index']) >>> df_groups = [grouped.get_group(x) for x in grouped.groups] >>> list_df = gg.visualization.add_row_to_boreholes(df_groups) >>> list_df[0] Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 NaN GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 NaN 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
See also
create_lines_from_points
Creating lines from points
create_borehole_tube
Creating borehole tube
create_borehole_tubes
Creating tubes from lines
create_borehole_labels
Creating labels for boreholes
create_boreholes_3d
Creating PyVista objects for plotting
- gemgis.visualization.calculate_vector(dip: Union[float, int], azimuth: Union[float, int]) numpy.ndarray #
Calculating the plunge vector of a borehole section
- Parameters
dip (Union[float, int]) – Dipping value of a borehole segment, e.g.
dip=90
azimuth (Union[float, int]) – Dipping direction of a borehole segment, e.g.
azimuth=20
- Returns
vector – Plunging/dipping vector of a borehole segment
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and define dip and azimuth >>> import gemgis as gg >>> dip = 90 >>> azimuth = 20
>>> # Calculating plunging vector >>> vector = gg.visualization.calculate_vector(dip=dip, azimuth=azimuth) >>> vector array([[ 0.364824 ], [-0.18285081], [ 0.91294525]])
- gemgis.visualization.clip_seismic_data(seismic_data, cdp_start: Optional[int] = None, cdp_end: Optional[int] = None) pandas.core.frame.DataFrame #
Clipping seismic data loaded with segysak to CDP defined start and end CDP values
- Parameters
seismic_data (xarray.core.dataset.Dataset) – seismic data loaded with the segysak package
cdp_start (Union[int, type(None)]) – Value for the start CDP number, e.g.
cdp_start=100
, default is'None'
cdp_end (Union[int, type(None)]) – Value for the end CDP number, e.g.
cdp_start=200
, default is'None'
- Returns
df_seismic_data_selection – DataFrame containing the clipped seismic data
- Return type
pd.DataFrame
New in version 1.0.x.
- gemgis.visualization.convert_to_rgb(array: numpy.ndarray) numpy.ndarray #
Converting array values to RGB values
- Parameters
array (np.ndarray) – Array containing the different bands of a raster
- Returns
array_stacked – Array with converted array values to RGB values
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and showing predefined array >>> import gemgis as gg >>> import numpy as np >>> array array([[0.3647059 , 0.3647059 , 0.49411765], [0.40784314, 0.40784314, 0.52156866], [0.8901961 , 0.8901961 , 0.91764706], ..., [0.59607846, 0.69803923, 0.8 ], [0.627451 , 0.7372549 , 0.7882353 ], [0.80784315, 0.78431374, 0.70980394]], dtype=float32)
>>> # Inspecting shape of array >>> array.shape (2000, 2800, 3)
>>> # Converting to RGB array >>> array_stacked = gg.visualization.convert_to_rgb(array=array) >>> array_stacked array([[[ 93, 93, 126], [104, 104, 133], [227, 227, 234], ..., [152, 178, 204], [160, 188, 201], [206, 200, 181]], [[247, 246, 248], [241, 240, 246], [243, 241, 241], ..., [150, 177, 205], [175, 187, 177], [232, 228, 219]]], dtype=uint8)
>>> # Inspecting shape of array >>> array_stacked.shape (2000, 2800, 3)
See also
read_raster
Reading Digital Elevation Model as xarray
drape_array_over_dem
Draping an array of the Digital Elevation Model
- gemgis.visualization.create_borehole_labels(df: Union[pandas.core.frame.DataFrame, geopandas.geodataframe.GeoDataFrame]) pyvista.core.pointset.PolyData #
Create labels for borehole plots.
- Parameters
df (Union[pd.DataFrame, gpd.geodataframe.GeoDataFrame]) – (Geo-)DataFrame containing the borehole data.
- Returns
borehole_locations – Borehole locations with labels.
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Changed in version 1.1.1: Fixed a ValueError that was introduced with pandas>2.0.0.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Creating borehole labels >>> labels = gg.visualization.create_borehole_labels(df=df) >>> labels Header PolyData Information N Cells 2 N Points 2 X Bounds 3.239e+07, 3.240e+07 Y Bounds 5.753e+06, 5.763e+06 Z Bounds 6.000e+01, 1.070e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Labels Points 1 nan nan
See also
add_row_to_boreholes
Adding a row to each borehole for later processing.
create_lines_from_points
Creating lines from points.
create_borehole_tube
Creating borehole tube.
create_borehole_tubes
Creating tubes from lines.
create_boreholes_3d
Creating PyVista objects for plotting.
- gemgis.visualization.create_borehole_tube(df: pandas.core.frame.DataFrame, line: pyvista.core.pointset.PolyData, radius: Union[float, int]) pyvista.core.pointset.PolyData #
Creating a tube from a line for the 3D visualization of boreholes
- Parameters
df (pd.DataFrame) – DataFrame containing the borehole data
line (pv.core.pointset.PolyData) – PyVista line object
radius (Union[float,int]) – Radius of the tube, e.g.
'radius=10'
- Returns
tube – PolyData Object representing the borehole tube
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Adding row to DataFrames >>> grouped = df.groupby(['Index']) >>> df_groups = [grouped.get_group(x) for x in grouped.groups] >>> list_df = gg.visualization.add_row_to_boreholes(df_groups) >>> list_df[0] Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 NaN GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 NaN 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Creating Lines from points >>> line = gg.visualization.create_lines_from_points(df=list_df[0]) >>> line PolyData Information N Cells 39 N Points 20 X Bounds 3.239e+07, 3.239e+07 Y Bounds 5.763e+06, 5.763e+06 Z Bounds -5.849e+03, 1.070e+02 N Arrays 0
>>> # Creating Tubes from lines >>> tube = gg.visualization.create_borehole_tube(df=list_df[0], line=line, radius=100) >>> tube Header PolyData Information N Cells 418 N Points 1520 X Bounds 3.239e+07, 3.239e+07 Y Bounds 5.762e+06, 5.764e+06 Z Bounds -5.849e+03, 1.070e+02 N Arrays 2 Data Arrays Name Field Type N Comp Min Max scalars Points int32 1 0.000e+00 1.900e+01 TubeNormals Points float32 3 -1.000e+00 1.000e+00
See also
add_row_to_boreholes
Adding a row to each borehole for later processing
create_lines_from_points
Creating lines from points
create_borehole_tubes
Creating tubes from lines
create_borehole_labels
Creating labels for boreholes
create_boreholes_3d
Creating PyVista objects for plotting
- gemgis.visualization.create_borehole_tubes(df: pandas.core.frame.DataFrame, min_length: Union[float, int], radius: Union[int, float] = 10) Tuple[List[pyvista.core.pointset.PolyData], List[pandas.core.frame.DataFrame]] #
Creating PyVista Tubes for plotting boreholes in 3D
- Parameters
df (pd.DataFrame) – DataFrame containing the extracted borehole data
min_length (Union[float, int]) – Length defining the minimum depth of boreholes to be plotted, e.g.
min_length=1000
radius (Union[int, float]) – Radius of the boreholes plotted with PyVista, e.g.
radius=100
default is10
m
- Returns
tubes (List[pv.core.pointset.PolyData]) – List of PyVista PolyData Objects
df_groups (List[pd.DataFrame]) – List of DataFrames containing the borehole data
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Creating borehole tubes >>> tubes, df_groups = gg.visualization.create_borehole_tubes(df=df, min_length=1000, radius=100) >>> tubes[0] Header PolyData Information N Cells 418 N Points 1520 X Bounds 3.239e+07, 3.239e+07 Y Bounds 5.762e+06, 5.764e+06 Z Bounds -5.849e+03, 1.070e+02 N Arrays 2 Data Arrays Name Field Type N Comp Min Max scalars Points int32 1 0.000e+00 1.900e+01 TubeNormals Points float32 3 -1.000e+00 1.000e+00
See also
add_row_to_boreholes
Adding a row to each borehole for later processing
create_lines_from_points
Creating lines from points
create_borehole_tube
Creating borehole tube
create_borehole_labels
Creating labels for boreholes
create_boreholes_3d
Creating PyVista objects for plotting
- gemgis.visualization.create_boreholes_3d(df: pandas.core.frame.DataFrame, min_length: Union[float, int], color_dict: dict, radius: Union[float, int] = 10) Tuple[List[pyvista.core.pointset.PolyData], pyvista.core.pointset.PolyData, List[pandas.core.frame.DataFrame]] #
Plotting boreholes in 3D
- Parameters
df (pd.DataFrame) – DataFrame containing the extracted borehole data
min_length (Union[float, int]) – Value defining the minimum depth of boreholes to be plotted, e.g.
min_length=1000
color_dict (dict) – Dict containing the surface colors of the model
radius (Union[float, int]) – Values of the radius of the boreholes plotted with PyVista, e.g.
radius=100
, default is10
- Returns
tubes (List[pv.core.pointset.PolyData]) – List of PyVista tubes
labels (pv.core.pointset.PolyData) – PyVista PolyData with Borehole Labels
df_groups (List[pd.DataFrame]) – List containing DataFrames
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Creating tubes >>> tubes, labels, df_groups = gg.visualization.create_boreholes_3d(df=df, min_length=10, color_dict=color_dict, radius=1000) >>> tubes Information MultiBlock Values N Blocks 2 X Bounds 32385176.360, 32404939.830 Y Bounds 5751889.550, 5764283.150 Z Bounds -5849.000, 107.000 Blocks Index Name Type 0 Block-00 PolyData 1 Block-01 PolyData
>>> # Inspecting labels >>> labels Header PolyData Information N Cells 2 N Points 2 X Bounds 3.239e+07, 3.240e+07 Y Bounds 5.753e+06, 5.763e+06 Z Bounds 6.000e+01, 1.070e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Labels Points 1 nan nan
See also
add_row_to_boreholes
Adding a row to each borehole for later processing
create_lines_from_points
Creating lines from points
create_borehole_tube
Creating borehole tube
create_borehole_tubes
Creating tubes from lines
create_borehole_labels
Creating labels for boreholes
- gemgis.visualization.create_delaunay_mesh_from_gdf(gdf: geopandas.geodataframe.GeoDataFrame, z: str = 'Z') pyvista.core.pointset.PolyData #
Creating a delaunay triangulated mesh from surface contour lines
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing LineStrings representing surface contours
- Returns
mesh – Mesh representing the triangulated mesh
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf OBJECTID Z EINHEIT Shape_Leng geometry 0 1.00 -2450 gg_kru_b_l_Z50m 3924.67 LINESTRING (32403313.109 5785053.637, 32402917... 1 2.00 -2400 gg_kru_b_l_Z50m 26332.90 LINESTRING (32410198.859 5781110.785, 32409807... 2 3.00 -2350 gg_kru_b_l_Z50m 31104.28 LINESTRING (32409587.930 5780538.824, 32408824... 3 4.00 -2300 gg_kru_b_l_Z50m 35631.73 LINESTRING (32408977.008 5779966.863, 32408808... 4 5.00 -2250 gg_kru_b_l_Z50m 41702.52 LINESTRING (32407319.922 5779788.672, 32407246...
>>> # Creating PolyData from isolines >>> mesh = gg.visualization.create_delaunay_mesh_from_gdf(gdf=gdf) >>> mesh Header PolyData Information N Cells 45651 N Points 23009 X Bounds 3.233e+07, 3.250e+07 Y Bounds 5.702e+06, 5.798e+06 Z Bounds -2.450e+03, 4.000e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Depth [m] Points float64 1 -2.450e+03 4.000e+02
See also
create_polydata_from_msh
Creating PolyData dataset from Leapfrog mesh file
create_polydata_from_ts
Creating PolyData dataset from GoCAD Tsurface file
create_polydata_from_dxf
Creating PolyData dataset from DXF object
- gemgis.visualization.create_dem_3d(dem: Union[rasterio.io.DatasetReader, numpy.ndarray], extent: List[Union[int, float]] = None, res: int = 1) pyvista.core.pointset.StructuredGrid #
Plotting the dem in 3D with PyVista
- Parameters
dem (Union[rasterio.io.DatasetReader, np.ndarray]) – Rasterio object or NumPy array containing the height values
extent (List[Union[int, float]]) – List containing the bounds of the raster, e.g.
extent=[0, 972, 0, 1069]
res (int) – Resolution of the meshgrid, e.g.
resolution=1
, default is1
- Returns
grid – Grid storing the elevation data
- Return type
pyvista.core.pointset.StructuredGrid
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import rasterio >>> raster = rasterio.open(fp='raster.tif')
>>> # Defining raster extent >>> extent = [0, 972, 0, 1069]
>>> # Creating mesh from raster data >>> grid = gg.visualization.create_dem_3d(dem=raster.read(1), extent=extent) >>> grid Header StructuredGrid Information N Cells 1037028 N Points 1039068 X Bounds 0.000e+00, 9.710e+02 Y Bounds 0.000e+00, 1.068e+03 Z Bounds 2.650e+02, 7.300e+02 Dimensions 1069, 972, 1 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Elevation Points float64 1 2.656e+02 7.305e+02
See also
create_lines_3d_polydata
Creating a mesh from lines
create_points_3d
Creating a mesh from points
- gemgis.visualization.create_depth_map(mesh: pyvista.core.pointset.PolyData, name: str = 'Depth [m]') pyvista.core.pointset.PolyData #
Extracting the depth values of the vertices and add them as scalars to the mesh
- Parameters
mesh (pv.core.pointset.PolyData) – PyVista PolyData dataset
name (str) – Name of the data array, e.g.
name='Depth [m]'
, default is'Depth [m]'
- Returns
mesh – PyVista PolyData dataset with depth values as data array
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pyvista as pv >>> mesh = pv.read(filename='mesh.vtk') >>> mesh PolyData Information N Cells 4174 N Points 2303 X Bounds 9.720e+00, 9.623e+02 Y Bounds 1.881e+02, 9.491e+02 Z Bounds 3.050e+02, 7.250e+02 N Arrays 0
>>> # Creating depth map from surface >>> mesh = gg.visualization.create_depth_map(mesh=mesh) >>> mesh Header PolyData Information N Cells 4174 N Points 2303 X Bounds 9.720e+00, 9.623e+02 Y Bounds 1.881e+02, 9.491e+02 Z Bounds 3.050e+02, 7.250e+02 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Depth [m] Points float64 1 3.050e+02 7.250e+02
See also
create_depth_maps_from_gempy
Creating depth maps from GemPy Model Surfaces
create_thickness_maps
Creating thickness map from PolyData datasets
create_temperature_map
Creating temperature map from PolyData datasets
- gemgis.visualization.create_depth_maps_from_gempy(geo_model, surfaces: Union[str, List[str]]) Dict[str, List[Union[pyvista.core.pointset.PolyData, numpy.ndarray, List[str]]]] #
Creating depth map of model surfaces, adapted from https://github.com/cgre-aachen/gempy/blob/20550fffdd1ccb3c6a9a402bc162e7eed3dd7352/gempy/plot/vista.py#L440-L477
- Parameters
geo_model (gp.core.model.Project) – Previously calculated GemPy Model
surfaces (Union[str, List[str]]) – Name of the surface or list with surface names of which the depth maps are created, e.g.
surfaces=['Layer1', 'Layer2']
- Returns
surfaces_poly – Dict containing the mesh data, depth data and color data for selected surfaces
- Return type
Dict[str, List[Union[pv.core.pointset.PolyData, np.ndarray, List[str]]]]
New in version 1.0.x.
Changed in version 1.1.8: Ensure compatibility with GemPy>=3
Example
>>> # Loading Libraries and creating depth map >>> import gemgis as gg >>> dict_sand1 = gg.visualization.create_depth_maps(geo_model=geo_model, surfaces='Sand1') >>> dict_sand1 {'Sand1': [PolyData (0x2dd0f46c820) N Cells: 4174 N Points: 2303 X Bounds: 9.720e+00, 9.623e+02 Y Bounds: 1.881e+02, 9.491e+02 Z Bounds: 3.050e+02, 7.250e+02 N Arrays: 1, '#015482']}
See also
create_depth_map
Creating depth map from PolyData dataset
create_thickness_maps
Creating thickness map from PolyData datasets
create_temperature_map
Creating temperature map from PolyData datasets
- gemgis.visualization.create_deviated_borehole_df(df_survey: pandas.core.frame.DataFrame, position: Union[numpy.ndarray, shapely.geometry.point.Point], depth: str = 'depth', dip: str = 'dip', azimuth: str = 'azimuth') pandas.core.frame.DataFrame #
Creating Pandas DataFrame containing parameters to create 3D boreholes
- Parameters
df_survey (pd.DataFrame) – Pandas DataFrame containing the survey data of one borehole
position (np.ndarray) – NumPy array containing the X, Y, and Z coordinates/the position of the borehole, e.g.
position = np.array([12012.68053 , 30557.53476 , 2325.532416])
depth (str) – Name of the column that contains the depth values, e.g.
depth='depth'
, default is'depth'
dip (str) – Name of the column that contains the dip values, e.g.
dip='dip'
, default is'dip'
azimuth (str) – Name of the column that contains the azimuth values, e.g.
azimuth='azimuth'
default is'azimuth'
- Returns
df_survey – Pandas DataFrame containing parameters to create 3D boreholes
- Return type
pd.DataFrame
New in version 1.0.x.
Changed in version 1.1.7.
Replace pandas append with concat.
Example
>>> # Loading Libraries and file >>> import gemgis as gg >>> import pandas as pd >>> df_survey = pd.read_csv('survey.csv') holeid depth dip azimuth 0 SonicS_006 0 90.00 20 1 SonicS_006 10 89.50 20 2 SonicS_006 20 89.00 20 3 SonicS_006 30 88.50 20 4 SonicS_006 40 88.00 20
>>> # Defining the position of the borehole at the surface >>> position = np.array([12012.68053 , 30557.53476 , 2325.532416])
>>> # Creating the survey DataFrame with additional parameters >>> df_survey = gg.visualization.create_deviated_well_df(df_survey=df_survey,position=position)
- gemgis.visualization.create_deviated_boreholes_3d(df_collar: pandas.core.frame.DataFrame, df_survey: pandas.core.frame.DataFrame, min_length: Union[float, int], radius: Union[float, int] = 10, collar_depth: str = 'Depth', survey_depth: str = 'Depth', index: str = 'Index', dip: str = 'dip', azimuth: str = 'azimuth') Tuple[List[pyvista.core.pointset.PolyData], pyvista.core.pointset.PolyData, List[pandas.core.frame.DataFrame]] #
Plotting boreholes in 3D
- Parameters
df_collar (pd.DataFrame) – DataFrame containing the extracted borehole data
df_survey (pd.DataFrame) – DataFrame containing the extracted borehole survey data
min_length (Union[float, int]) – Value defining the minimum depth of boreholes to be plotted, e.g.
min_length=1000
color_dict (dict) – Dict containing the surface colors of the model
radius (Union[float, int]) – Values of the radius of the boreholes plotted with PyVista, e.g.
radius=100
, default is10
collar_depth (str) – Name of the column that contains the depth values, e.g.
collar_depth='depth'
, default is'Depth'
survey_depth (str) – Name of the column that contains the depth values, e.g.
survey_depth='depth'
, default is'Depth'
index (str) – Name of the column that contains the index values, e.g.
index='index'
, default is'index'
dip (str) – Name of the column that contains the dip values, e.g.
dip='dip'
, default is'dip'
azimuth (str) – Name of the column that contains the azimuth values, e.g.
azimuth='azimuth'
default is'azimuth'
- Returns
tubes (List[pv.core.pointset.PolyData]) – List of PyVista tubes
labels (pv.core.pointset.PolyData) – PyVista PolyData with Borehole Labels
df_groups (List[pd.DataFrame]) – List containing DataFrames
New in version 1.0.x.
Example
- gemgis.visualization.create_lines_3d_linestrings(gdf: geopandas.geodataframe.GeoDataFrame, dem: Union[rasterio.io.DatasetReader, numpy.ndarray], extent: List[Union[int, float]] = None) geopandas.geodataframe.GeoDataFrame #
Creating lines with z-component (LineString Z)
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the LineStrings to be converted to linestrings with z-component
dem (Union[rasterio.io.DatasetReader, np.ndarray]) – Rasterio object or NumPy array containing the height values
extent (List[Union[int, float]]) – List containing the bounds of the raster, e.g.
extent=[0, 972, 0, 1069]
- Returns
gdf_3d – GeoDataFrame containing the LineStrings with Z component (LineString Z)
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> import rasterio >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Unterjura LINESTRING (32522415.430 5777985.396, 32521520... 1 None Unterjura LINESTRING (32479802.616 5782183.163, 32480593... 2 None Mitteljura LINESTRING (32522376.263 5779907.729, 32520580... 3 None Mitteljura LINESTRING (32463272.196 5788327.350, 32464107...
>>> # Loading Digital Elevation Model >>> dem = rasterio.open('raster.tif')
>>> # Create LineStrings with Z-component >>> gdf_3d = gg.visualization.create_lines_3d_linestrings(gdf=gdf, dem=dem) >>> gdf_3d id formation geometry 0 None Unterjura LINESTRING Z (32522415.430 5777985.396 213.000... 1 None Unterjura LINESTRING Z (32479802.616 5782183.163 84.000,... 2 None Mitteljura LINESTRING Z (32522376.263 5779907.729 116.000... 3 None Mitteljura LINESTRING Z (32463272.196 5788327.350 102.000...
See also
create_lines_3d_polydata
Creating lines with z-component for the plotting with PyVista
create_dem_3d
Creating a mesh from a Digital Elevation Model
create_points_3d
Creating a mesh from points
- gemgis.visualization.create_lines_3d_polydata(gdf: geopandas.geodataframe.GeoDataFrame) pyvista.core.pointset.PolyData #
Creating lines with z-component for the plotting with PyVista
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the contour information
- Returns
poly – PyVista Polydata Set containing the lines and vertices
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id Z geometry 0 None 400 LINESTRING (0.741 475.441, 35.629 429.247, 77.... 1 None 300 LINESTRING (645.965 0.525, 685.141 61.866, 724... 2 None 400 LINESTRING (490.292 0.525, 505.756 40.732, 519... 3 None 600 LINESTRING (911.433 1068.585, 908.856 1026.831... 4 None 700 LINESTRING (228.432 1068.585, 239.772 1017.037...
>>> # Create mesh from LineStrings >>> polydata = gg.visualization.create_lines_3d_polydata(gdf=gdf) >>> polydata PolyData Information N Cells 7 N Points 121 X Bounds 7.409e-01, 9.717e+02 Y Bounds 5.250e-01, 1.069e+03 Z Bounds 3.000e+02, 7.000e+02 N Arrays 0
See also
create_dem_3d
Creating a mesh from a Digital Elevation Model
create_points_3d
Creating a mesh from points
- gemgis.visualization.create_lines_from_points(df: pandas.core.frame.DataFrame) pyvista.core.pointset.PolyData #
Creating a line set from a Pandas DataFrame
- Parameters
df (pd.DataFrame) – Pandas DataFrame containing the data for one borehole
- Returns
poly – Creating borehole traces from points
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv') >>> df Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Adding row to DataFrames >>> grouped = df.groupby(['Index']) >>> df_groups = [grouped.get_group(x) for x in grouped.groups] >>> list_df = gg.visualization.add_row_to_boreholes(df_groups) >>> list_df[0] Unnamed: 0 Index Name X Y Z Altitude Depth formation geometry 0 NaN GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 NaN 0 2091 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 27.00 107.00 5956.00 OberCampanium POINT (32386176.36 5763283.15) 1 2092 GD1017 ForschungsbohrungMünsterland1 32386176.36 5763283.15 -193.00 107.00 5956.00 UnterCampanium POINT (32386176.36 5763283.15)
>>> # Creating Lines from points >>> line = gg.visualization.create_lines_from_points(df=list_df[0]) >>> line PolyData Information N Cells 39 N Points 20 X Bounds 3.239e+07, 3.239e+07 Y Bounds 5.763e+06, 5.763e+06 Z Bounds -5.849e+03, 1.070e+02 N Arrays 0
See also
add_row_to_boreholes
Adding a row to each borehole for later processing
create_borehole_tube
Creating borehole tube
create_borehole_tubes
Creating tubes from lines
create_borehole_labels
Creating labels for boreholes
create_boreholes_3d
Creating PyVista objects for plotting
- gemgis.visualization.create_mesh_from_cross_section(linestring: shapely.geometry.linestring.LineString, zmax: Union[float, int], zmin: Union[float, int]) pyvista.core.pointset.PolyData #
Creating a PyVista Mesh from one cross section
- Parameters
linestring (shapely.geometry.linestring.LineString) – LineString representing the trace of the cross section on a geological map, e.g.
linestring = LineString([(0, 0), (10, 10), (20, 20)])
zmax (Union[float, int]) – Upper vertical extent of the cross section, e.g.
zmax=1000
zmin (Union[float, int]) – Lower vertical extent of the cross section, e.g.
zmin=0
- Returns
surface – Mesh defining the cross section in space
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and creating LineString >>> import gemgis as gg >>> from shapely.geometry import LineString >>> linestring = LineString([(0, 0), (10, 10), (20, 20)]) >>> linestring.wkt 'LINESTRING (0 0, 10 10, 20 20)'
>>> # Creating PolyData from LineStrings >>> polydata = gg.visualization.create_mesh_from_cross_section(linestring=linestring, zmax=1000, zmin=0) >>> polydata Header PolyData Information N Cells 4 N Points 6 X Bounds 0.000e+00, 2.000e+01 Y Bounds 0.000e+00, 2.000e+01 Z Bounds 0.000e+00, 1.000e+03 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Texture Coordinates Points float64 2 0.000e+00 1.000e+00
See also
create_meshes_from_cross_sections
Creating meshes from cross sections
- gemgis.visualization.create_meshes_from_cross_sections(gdf: geopandas.geodataframe.GeoDataFrame) List[pyvista.core.pointset.PolyData] #
Creating PyVista Meshes from multiple cross section
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the traces of the profiles as LineStrings
- Returns
meshes_list – List containing the meshes of all profiles
- Return type
List[pyvista.core.pointset.PolyData]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id zmax zmin name geometry 0 None 500 -6000 Muenster LINESTRING (32386148.890 5763304.720, 32393549... 1 None 500 -2000 Rheine LINESTRING (32402275.136 5761828.501, 32431165...
>>> # Creating list of PolyData datasets from GeoDataFrame >>> meshes_list = gg.visualization.create_meshes_from_cross_sections(gdf=gdf) >>> meshes_list [PolyData (0x2526e543ee0) N Cells: 20 N Points: 22 X Bounds: 3.239e+07, 3.242e+07 Y Bounds: 5.717e+06, 5.763e+06 Z Bounds: -6.000e+03, 5.000e+02 N Arrays: 1, PolyData (0x2526a4687c0) N Cells: 2 N Points: 4 X Bounds: 3.240e+07, 3.243e+07 Y Bounds: 5.762e+06, 5.814e+06 Z Bounds: -2.000e+03, 5.000e+02 N Arrays: 1]
See also
create_mesh_from_cross_section
Creating a mesh from a cross section
- gemgis.visualization.create_meshes_hypocenters(gdf: geopandas.geodataframe.GeoDataFrame, magnitude: str = 'Magnitude', magnitude_factor: int = 200, year: str = 'Year') pyvista.core.composite.MultiBlock #
Plotting earthquake hypocenters with PyVista
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the earthquake hypocenter data
magnitude (str) – Name for the column containing the magnitude value, e.g.
magnitude='Magnitude'
, default is'Magnitude'
magnitude_factor (int) – Scaling factor for the magnitude values defining the size of the spheres, e.g.
magnitude_factor=200
, default is200
year (str) – Name for the column containing the year of each earthquake event, e.g.
year='Year'
, default to'Year'
- Returns
spheres – PyVista MultiBlock object containing the hypocenters stored as spheres
- Return type
pv.core.composite.MultiBlock
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf Y X Z RASTERVALU Tiefe [km] Magnitude Epizentrum Year geometry 0 5645741.63 32322660.15 -8249.25 150.75 8.40 1.50 STETTERNICH 2002 POINT (32322660.151 5645741.630) 1 5645947.18 32323159.51 89.63 89.63 0.00 0.80 SOPHIENHOEHE 2014 POINT (32323159.505 5645947.183)
>>> # Creating Spheres for hypocenters >>> spheres = gg.visualization.create_meshes_hypocenters(gdf=gdf) >>> spheres Information MultiBlock Values N Blocks 497 X Bounds 32287780.000, 32328260.000 Y Bounds 5620074.000, 5648385.000 Z Bounds -24317.020, 309.130 Blocks Index Name Type 0 Block-00 PolyData 1 Block-01 PolyData 2 Block-02 PolyData
- gemgis.visualization.create_points_3d(gdf: geopandas.geodataframe.GeoDataFrame) pyvista.core.pointset.PolyData #
Plotting points in 3D with PyVista
- Parameters
points (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the points including X, Y, and Z columns
- Returns
points_mesh – PyVista PolyData Pointset
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Creating PolyData from points >>> polydata = gg.visualization.create_points_3d(gdf=gdf) >>> polydata PolyData Information N Cells 41 N Points 41 X Bounds 8.841e+00, 9.661e+02 Y Bounds 1.650e+02, 1.045e+03 Z Bounds 2.769e+02, 7.220e+02 N Arrays 0
See also
create_lines_3d_polydata
Creating a mesh from lines
create_dem_3d
Creating a mesh from a Digital Elevation model
- gemgis.visualization.create_polydata_from_dxf(gdf: geopandas.geodataframe.GeoDataFrame) pyvista.core.pointset.PolyData #
Converting loaded DXF object to PyVista PolyData
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame containing the faces/polygons of the loaded DXF object
- Returns
polydata – PyVista PolyData containing the mesh values
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.dxf') >>> gdf geometry 0 POLYGON Z ((1.00869 0.92852 1.00000, 0.97744 0... 1 POLYGON Z ((1.00869 0.92852 1.00000, 1.01735 0... 2 POLYGON Z ((0.97744 0.92853 1.00000, 0.94619 0... 3 POLYGON Z ((0.97744 0.92853 1.00000, 0.98610 0... 4 POLYGON Z ((0.94619 0.92853 1.00000, 0.91494 0...
>>> # Creating PolyData from dxf file >>> polydata = gg.visualization.create_polydata_from_dxf(gdf=gdf) >>> polydata PolyData Information N Cells 98304 N Points 393216 X Bounds -1.576e+00, 2.530e+00 Y Bounds -9.751e+00, 1.000e+00 Z Bounds -9.167e-01, 1.000e+00 N Arrays 0
See also
create_polydata_from_msh
Creating PolyData dataset from Leapfrog mesh file
create_polydata_from_ts
Creating PolyData dataset from GoCAD Tsurface file
create_structured_grid_from_asc
Creating StructuredGrid vom ESRI ASC Grid
create_structured_grid_from_zmap
Creating StructuredGrid vom Petrel ZMAP Grid
create_delaunay_mesh_from_gdf
Create Mesh from GeoDataFrame containing contour lines
- gemgis.visualization.create_polydata_from_msh(data: Dict[str, numpy.ndarray]) pyvista.core.pointset.PolyData #
Converting loaded Leapfrog mesh to PyVista PolyData
- Parameters
data (Dict[str, np.ndarray]) – Dict containing the data loaded from a Leapfrog mesh with read_msh() of the raster module
- Returns
polydata – PyVista PolyData containing the mesh values
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> data = gg.raster.read_msh('mesh.msh') >>> data {'Tri': array([[ 0, 1, 2], [ 0, 3, 1], [ 4, 3, 0], ..., [53677, 53672, 53680], [53679, 53677, 53680], [53673, 53672, 53677]]), 'Location': array([[ 1.44625109e+06, 5.24854344e+06, -1.12743862e+02], [ 1.44624766e+06, 5.24854640e+06, -1.15102216e+02], [ 1.44624808e+06, 5.24854657e+06, -1.15080548e+02], ..., [ 1.44831008e+06, 5.24896679e+06, -1.24755449e+02], [ 1.44830385e+06, 5.24896985e+06, -1.33694397e+02], [ 1.44829874e+06, 5.24897215e+06, -1.42506587e+02]])}
>>> # Creating PolyData from msh file >>> polydata = gg.visualization.create_polydata_from_msh(data=data) >>> polydata PolyData Information N Cells 107358 N Points 53681 X Bounds 1.444e+06, 1.449e+06 Y Bounds 5.246e+06, 5.249e+06 Z Bounds -2.464e+02, 7.396e+02 N Arrays 0
See also
create_polydata_from_ts
Creating PolyData dataset from GoCAD Tsurface file
create_polydata_from_dxf
Creating PolyData dataset from DXF object
create_structured_grid_from_asc
Creating StructuredGrid vom ESRI ASC Grid
create_structured_grid_from_zmap
Creating StructuredGrid vom Petrel ZMAP Grid
create_delaunay_mesh_from_gdf
Create Mesh from GeoDataFrame containing contour lines
- gemgis.visualization.create_polydata_from_ts(data: Tuple[list, list], concat: bool = False) pyvista.core.pointset.PolyData #
Converting loaded GoCAD mesh to PyVista PolyData
- Parameters
data (Tuple[list, list]) – Tuple containing the data loaded from a GoCAD mesh with read_ts() of the raster module
concat (bool) – Boolean defining whether the DataFrames should be concatenated or not
- Returns
polydata – PyVista PolyData containing the mesh values
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> vertices, faces = gg.raster.read_ts('mesh.ts')
>>> # Inspecting vertices >>> vertices id X Y Z 0 0 297077.41 5677487.26 -838.50 1 1 297437.54 5676992.09 -816.61
>>> # Inspecting >>> faces array([[ 0, 1, 2], [ 3, 2, 4], [ 1, 5, 6],..., [40335, 40338, 40336], [40339, 40340, 40341], [40341, 40342, 40339]])
>>> # Creating PolyData from ts file >>> polydata = gg.visualization.create_polydata_from_ts((vertices, faces)) >>> polydata PolyData Information N Cells 29273 N Points 40343 X Bounds 2.804e+05, 5.161e+05 Y Bounds 5.640e+06, 5.833e+06 Z Bounds -8.067e+03, 1.457e+02 N Arrays 0
See also
create_polydata_from_msh
Creating PolyData dataset from Leapfrog mesh file
create_polydata_from_dxf
Creating PolyData dataset from DXF object
create_structured_grid_from_asc
Creating StructuredGrid vom ESRI ASC Grid
create_structured_grid_from_zmap
Creating StructuredGrid vom Petrel ZMAP Grid
create_delaunay_mesh_from_gdf
Create Mesh from GeoDataFrame containing contour lines
- gemgis.visualization.create_structured_grid_from_asc(data: dict) pyvista.core.pointset.StructuredGrid #
Converting loaded ASC object to PyVista StructuredGrid
- Parameters
data (dict) – Dict containing the extracted ASC data using read_asc(…) of the raster module
- Returns
grid – PyVista StructuredGrid created from ASC data
- Return type
pv.core.pointset.StructuredGrid
New in version 1.0.x.
Example
>>> # Loading Libraries and data >>> import gemgis as gg >>> data = gg.raster.read_asc('raster.asc')
>>> # Creating StructuredGrid from data >>> grid = gg.visualization.create_structured_grid_from_asc(data=data) >>> grid Header Data Arrays StructuredGrid Information N Cells 2880012 N Points 2883540 X Bounds -4.225e+04, 2.788e+05 Y Bounds 3.060e+05, 8.668e+05 Z Bounds -1.000e+05, 2.880e+02 Dimensions 2244, 1285, 1 N Arrays 1 Name Field Type N Comp Min Max Depth [m] Points float64 1 -1.132e+04 2.887e+02
See also
create_polydata_from_msh
Creating PolyData dataset from Leapfrog mesh file
create_polydata_from_ts
Creating PolyData dataset from GoCAD Tsurface file
create_polydata_from_dxf
Creating PolyData dataset from DXF object
create_structured_grid_from_zmap
Creating StructuredGrid vom Petrel ZMAP Grid
create_delaunay_mesh_from_gdf
Create Mesh from GeoDataFrame containing contour lines
- gemgis.visualization.create_structured_grid_from_zmap(data: dict) pyvista.core.pointset.StructuredGrid #
Converting loaded ZMAP object to PyVista StructuredGrid
- Parameters
data (dict) – Dict containing the extracted ZAMP data using read_zmap(…) of the raster module
- Returns
grid – PyVista StructuredGrid created from zmap data
- Return type
pv.core.pointset.StructuredGrid
New in version 1.0.x.
Example
>>> # Loading Libraries and data >>> import gemgis as gg >>> data = gg.raster.read_zmap('raster.dat')
>>> # Creating StructuredGrid from data >>> grid = gg.visualization.create_structured_grid_from_zmap(data=data) >>> grid Header Data Arrays StructuredGrid Information N Cells 2880012 N Points 2883540 X Bounds -4.225e+04, 2.788e+05 Y Bounds 3.060e+05, 8.668e+05 Z Bounds -1.000e+05, 2.880e+02 Dimensions 2244, 1285, 1 N Arrays 1 Name Field Type N Comp Min Max Depth [m] Points float64 1 -1.132e+04 2.887e+02
See also
create_polydata_from_msh
Creating PolyData dataset from Leapfrog mesh file
create_polydata_from_ts
Creating PolyData dataset from GoCAD Tsurface file
create_polydata_from_dxf
Creating PolyData dataset from DXF object
create_structured_grid_from_asc
Creating StructuredGrid vom ESRI ASC Grid
create_delaunay_mesh_from_gdf
Create Mesh from GeoDataFrame containing contour lines
- gemgis.visualization.create_temperature_map(dem: rasterio.io.DatasetReader, mesh: pyvista.core.pointset.PolyData, name: str = 'Thickness [m]', apply_threshold: bool = True, tsurface: Union[float, int] = 10, gradient: Union[float, int] = 0.03) pyvista.core.pointset.PolyData #
Creating a temperature map for a surface at depth taking the topography into account
- Parameters
dem (rasterio.io.DatasetReader) – Digital Elevation Model of the area
mesh (pv.core.pointset.PolyData) – PolyData dataset for which the temperature at depth will be calculated
name (str) – Name of the array to be added to the mesh, e.g.
name='Thickness [m]'
, default is'Thickness [m]'
apply_threshold (bool) – Variable to apply a threshold to the mesh to remove vertices that were located above the topography. Options include:
True
orFalse
, default set toTrue
tsurface (Union[float, int]) – Surface temperature in degrees Celsius, e.g.
tsurface=10
, default is10
degrees Cgradient (Union[float, int]) – Geothermal gradient in degrees celsius per meter, e.g.
gradient=0.03
, default is0.03
degrees C per m
- Returns
mesh – PolyData dataset including a temperature data array
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and Files >>> import gemgis as gg >>> import rasterio >>> import pyvista as pv >>> dem = rasterio.open(fp='raster.tif') >>> mesh = pv.read(filename='mesh1.vtk') >>> mesh PolyData Information N Cells 4174 N Points 2303 X Bounds 9.720e+00, 9.623e+02 Y Bounds 1.881e+02, 9.491e+02 Z Bounds 3.050e+02, 7.250e+02 N Arrays 0
>>> # Creating temperature map >>> mesh = gg.visualization.create_temperature_map(dem=dem, mesh=mesh) >>> mesh Header UnstructuredGrid Information N Cells 3946 N Points 2130 X Bounds 9.720e+00, 9.623e+02 Y Bounds 1.881e+02, 9.491e+02 Z Bounds 3.050e+02, 7.250e+02 N Arrays 2 Data Arrays Name Field Type N Comp Min Max Thickness [m] Points float64 1 9.321e-02 2.020e+02 Temperature [°C] Points float64 1 1.000e+01 1.606e+01
See also
create_depth_map
Creating depth map from PolyData dataset
create_depth_maps_from_gempy
Creating depth maps from GemPy Model Surfaces
create_thickness_maps
Creating thickness map from PolyData datasets
- gemgis.visualization.create_thickness_maps(top_surface: pyvista.core.pointset.PolyData, base_surface: pyvista.core.pointset.PolyData) pyvista.core.pointset.PolyData #
Creating a thickness map using https://docs.pyvista.org/examples/01-filter/distance-between-surfaces.html#sphx-glr-examples-01-filter-distance-between-surfaces-py
- Parameters
top_surface (pv.core.pointset.PolyData) – Mesh representing the top of the layer
base_surface (pv.core.pointset.PolyData) – Mesh representing the base of the layer
- Returns
thickness – Mesh with scalars representing the thickness of the layer
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and creating thickness map >>> import gemgis as gg >>> dict_all = gg.visualization.create_depth_maps_from_gempy(geo_model=geo_model, surfaces=['Sand1', 'Ton']) >>> thickness_map = gg.visualization.create_thickness_maps(top_surface=dict_all['Sand1'][0], base_surface=dict_all['Ton'][0]) >>> thickness_map Header PolyData Information N Cells 5111 N Points 2739 X Bounds 9.720e+00, 9.623e+02 Y Bounds 3.578e+02, 1.058e+03 Z Bounds 3.050e+02, 7.265e+02 N Arrays 3 Data Arrays Name Field Type N Comp Min Max Data Points float64 1 3.050e+02 7.265e+02 Normals Points float32 3 -9.550e-01 6.656e-01 Thickness [m] Points float64 1 4.850e+01 8.761e+01
See also
create_depth_map
Creating depth map from PolyData dataset
create_depth_maps_from_gempy
Creating depth maps from GemPy Model Surfaces
create_temperature_map
Creating temperature map from PolyData datasets
- gemgis.visualization.drape_array_over_dem(array: numpy.ndarray, dem: Union[rasterio.io.DatasetReader, numpy.ndarray], extent: List[Union[int, float]] = None, zmax: Union[float, int] = 10000, resize_array: bool = True)#
Creating grid and texture to drape array over a digital elevation model
- Parameters
array (np.ndarray) – Array containing the map data such as a WMS Map
dem (Union[rasterio.io.DatasetReader, np.ndarray]) – Digital elevation model where the array data is being draped over
extent (List[Union[float, int]]) – List containing the bounds of the raster, e.g.
extent=[0, 972, 0, 1069]
zmax (Union[float, int]) – Maximum z value to limit the elevation data, e.g.
zmax=1000
resize_array (bool) – Whether to resize the array or the dem if the shape of the dem does not match the shape of the array Options include:
True
orFalse
, default set toTrue
- Returns
mesh (pyvista.core.pointset.PolyData) – Mesh containing the Digital elevation model data
texture (pyvista.core.objects.Texture) – PyVista Texture containing the map data
New in version 1.0.x.
Changed in version 1.1: Function now allows rasters with different sizes and resizes one of the rasters automatically
Changed in version 1.1.2: Edit zmax value and fixing a bug with the scikit-image resize function, see https://github.com/cgre-aachen/gemgis/issues/303
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> array array([[[ 93, 93, 126], [104, 104, 133], [227, 227, 234], ..., [152, 178, 204], [160, 188, 201], [206, 200, 181]], [[247, 246, 248], [241, 240, 246], [243, 241, 241], ..., [150, 177, 205], [175, 187, 177], [232, 228, 219]]], dtype=uint8)
>>> # Inspecting Digital Elevation Model values >>> dem array([[ 0. , 0. , 0. , ..., 40.1 , 40.09, 44.58], [ 0. , 0. , 0. , ..., 40.08, 40.07, 44.21], [ 0. , 0. , 0. , ..., 40.14, 44.21, 43.98], ..., [100.56, 102.14, 102.17, ..., 0. , 0. , 0. ], [ 99.44, 99.85, 99.77, ..., 0. , 0. , 0. ], [ 88.32, 91.76, 98.68, ..., 0. , 0. , 0. ]], dtype=float32)
>>> # Draping mesh over array >>> mesh, texture = gg.visualization.drape_array_over_dem(array=array, dem=dem) >>> mesh Header StructuredGrid Information N Cells 5595201 N Points 5600000 X Bounds 3.236e+07, 3.250e+07 Y Bounds 5.700e+06, 5.800e+06 Z Bounds 0.000e+00, 5.038e+02 Dimensions 2000, 2800, 1 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Texture Coordinates Points float32 2 -7.077e-06 1.000e+00
>>> # Inspecting the texture >>> texture (Texture)00000151B91F3AC0
See also
read_raster
Reading Digital Elevation Model as xarray
convert_to_rgb
Converting bands to RGB values for plotting
- gemgis.visualization.get_batlow_cmap() matplotlib.colors.ListedColormap #
Returning the Batlow cmap from https://github.com/callumrollo/cmcrameri/blob/master/cmcrameri/cmaps/batlow.txt
- Returns
cmap_batlow – Batlow color map
- Return type
matplotlib.colors.ListedColormap
New in version 1.0.x.
- gemgis.visualization.get_color_lot(geo_model, lith_c: pandas.core.frame.DataFrame = None, index='surface', is_faults: bool = True, is_basement: bool = False) pandas.core.series.Series #
- Method to get the right color list depending on the type of plot.
Borrowed from https://github.com/cgre-aachen/gempy/blob/6aed72a4dfa26830df142a0461294bd9d21a4fa4/gempy/plot/vista.py#L133-L167
- Parameters
geo_model (gp.core.model.Project) – Previously calculated GemPy Model
lith_c (pd.DataFrame) – Pandas Series with index surface names and values hex strings with the colors
index (str) – Index provided as string, e.g.
index='surface'
, default is'surface'
is_faults (bool) – Return the colors of the faults. This should be true for surfaces and input data and false for scalar values. Options include
True
andFalse
, default isTrue
is_basement (bool) – Return or not the basement. This should be true for the lith block and false for surfaces and input data. Options include
True
andFalse
, default isFalse
New in version 1.0.x.
- gemgis.visualization.get_mesh_geological_map(geo_model) Tuple[pyvista.core.pointset.PolyData, matplotlib.colors.ListedColormap, bool] #
Getting the geological map of a GemPy Model draped over the topography as mesh. Borrowed from https://github.com/cgre-aachen/gempy/blob/6aed72a4dfa26830df142a0461294bd9d21a4fa4/gempy/plot/vista.py#L512-L604
- Parameters
geo_model (gp.core.model.Project) – Previously calculated GemPy Model
- Returns
polydata (pv.core.PolyData) – PyVista Mesh containing the geological map draped over the topography
cm (matplotlib.colors.ListedColormap) – Colormap for plotting
rgb (bool) – Boolean to use
rgb=True
when plotting
New in version 1.0.x.
- gemgis.visualization.get_petrel_cmap() matplotlib.colors.ListedColormap #
Returning the Petrel cmap
- Returns
cmap_seismic – Seismic color map
- Return type
matplotlib.colors.ListedColormap
New in version 1.0.x.
- gemgis.visualization.get_points_along_spline(spline: pyvista.core.pointset.PolyData, dist: numpy.ndarray)#
Returning the closest point on the spline a given a length along a spline.
- Parameters
spline (pv.core.pointset.PolyData) – Spline with the resampled vertices
dist (np.ndarray) – np.ndarray containing the measured depths (MD) of values along the well path
- Returns
spline.points[idx_list] – PyVista Array containing the selected points
- Return type
pv.core.pyvista_ndarray.pyvista_ndarray
New in version 1.0.x.
- gemgis.visualization.get_seismic_cmap() matplotlib.colors.ListedColormap #
Returning the seismic cmap from https://github.com/lperozzi/Seismic_colormaps/blob/master/colormaps.py
- Returns
cmap_seismic – Seismic color map
- Return type
matplotlib.colors.ListedColormap
New in version 1.0.x.
- gemgis.visualization.group_borehole_dataframe(df: pandas.core.frame.DataFrame) List[pandas.core.frame.DataFrame] #
Grouping Borehole DataFrame by Index
- Parameters
df (pd.DataFrame) – Pandas DataFrame containing the borehole data
- Returns
df_groups
- Return type
List[pd.DataFrame]
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pandas as pd >>> df = pd.read_csv('file.csv')
>>> # Creating groups >>> df_groups = gg.visualization.group_borehole_dataframe(df=df)
- gemgis.visualization.plane_through_hypocenters(spheres: pyvista.core.composite.MultiBlock) pyvista.core.pointset.PolyData #
Fitting a plane through the hypocenters of earthquakes using Eigenvector analysis
- Parameters
spheres (pv.core.composite.MultiBlock) – PyVista MultiBlock object containing the hypocenters stored as spheres
- Returns
plane – Plane fitting through the hypocenters using Eigenvector analysis
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import pyvista as pv >>> spheres = pv.read(filename='spheres.vtk')
>>> # Fitting plane through spheres >>> plane = gg.visualization.plane_through_hypocenters(spheres=spheres) >>> plane Header PolyData Information N Cells 100 N Points 121 X Bounds 3.230e+07, 3.231e+07 Y Bounds 5.618e+06, 5.620e+06 Z Bounds -1.113e+04, -8.471e+03 N Arrays 2 Data Arrays Name Field Type N Comp Min Max Normals Points float32 3 0.000e+00 1.000e+00 TextureCoordinates Points float32 2 0.000e+00 1.000e+00
- gemgis.visualization.plot_data(geo_data, show_basemap: bool = False, show_geolmap: bool = False, show_topo: bool = False, show_interfaces: bool = False, show_orientations: bool = False, show_customsections: bool = False, show_wms: bool = False, show_legend: bool = True, show_hillshades: bool = False, show_slope: bool = False, show_aspect: bool = False, show_contours: bool = False, add_to_extent: float = 0, hide_topo_left: bool = False, **kwargs)#
Plotting Input Data
- Parameters
geo_data – GemPy Geo Data Class containing the raw data
show_basemap (bool) – Showing the basemap. Options include
True
andFalse
, default isFalse
show_geolmap (bool) – Showing the geological map. Options include
True
andFalse
, default isFalse
show_topo (bool) – Showing the topography/digital elevation model. Options include
True
andFalse
, default isFalse
show_interfaces (bool) – Showing the interfaces. Options include
True
andFalse
, default isFalse
show_orientations (bool) – Showing orientations. Options include
True
andFalse
, default isFalse
show_customsections (bool) – Showing custom sections. Options include
True
andFalse
, default isFalse
show_wms (bool) – Showing a WMS layer. Options include
True
andFalse
, default isFalse
show_legend (bool) – Showing the legend of interfaces. Options include
True
andFalse
, default isFalse
show_hillshades (bool) – Showing hillshades. Options include
True
andFalse
, default isFalse
show_slope (bool) – Showing the slope of the DEM. Options include
True
andFalse
, default isFalse
show_aspect (bool) – Showing the aspect of the DEM. Options include
True
andFalse
, default isFalse
show_contours (bool) – Showing the contours of the DEM
add_to_extent (float) – Number of meters to add to the extent of the plot in each direction, e.g.
add_to_extent=10
, default is0
hide_topo_left (bool) – If set to
True
, the topography will not be shown in the left plot. Options includeTrue
andFalse
, default isFalse
cmap_basemap (str) – Cmap for basemap
cmap_geolmap (str) – Cmap for geological map
cmap_topo (str) – Cmap for topography
cmap_hillshades (str) – Cmap for hillshades
cmap_slope (str) – Cmap for slope
cmap_aspect (str) – Cmap for aspect
cmap_interfaces (str) – Cmap for interfaces
cmap_orientations (str) – Cmap for orientations
cmap_wms (str) – Cmap for WMS Service
cmap_contours (str) – Cmap for contour lines
New in version 1.0.x.
- gemgis.visualization.plot_orientations(gdf: Union[geopandas.geodataframe.GeoDataFrame, pandas.core.frame.DataFrame], show_planes: bool = True, show_density_contours: bool = True, show_density_contourf: bool = False, formation: str = None, method: str = 'exponential_kamb', sigma: Union[float, int] = 1, cmap: str = 'Blues_r')#
Plotting orientation values of a GeoDataFrame with mplstereonet
- Parameters
gdf (Union[gpd.geodataframe.GeoDataFrame, pd.DataFrame]) – (Geo-)DataFrame containing columns with orientations values
show_planes (bool) – Variable to show planes of orientation values. Options include:
True
orFalse
, default set toTrue
show_density_contours (bool) – Variable to display density contours. Options include:
True
orFalse
, default set toTrue
show_density_contourf (bool) – Variable to display density contourf. Options include:
True
orFalse
, default set toFalse
formation (str) – Name of the formation for which the contourf plot is shown, e.g.
formation='Layer1'
, default isNone
method (str) – Method to estimate the orientation density distribution,
method='exponential_kamb'
, default is'exponential_kamb'
sigma (Union[float, int]) – Expected count in standard deviations, e.g.
sigma=1
, default is1
cmap (str) – Name of the colormap for plotting the orientation densities, e.g.
cmap='Blues_r'
, default is'Blues_r'
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation dip azimuth geometry 0 None Sand 25.00 310 POINT (49.249 1033.893) 1 None Sand 30.00 315 POINT (355.212 947.557) 2 None Sand 15.00 330 POINT (720.248 880.912) 3 None Clay 10.00 135 POINT (526.370 611.300) 4 None Clay 25.00 140 POINT (497.591 876.368) 5 None Clay 35.00 50 POINT (394.593 481.039)
>>> # Creating plot >>> gg.visualization.plot_orientations(gdf=gdf, show_planes=True, show_density_contours=False, show_density_contourf=False)
- gemgis.visualization.polyline_from_points(points: numpy.ndarray) pyvista.core.pointset.PolyData #
Creating PyVista PolyLine from points
- Parameters
points (np.ndarray) – Points defining the PolyLine
- Returns
poly
- Return type
pv.core.pointset.PolyData
New in version 1.0.x.
- gemgis.visualization.read_raster(path=<class 'str'>, nodata_val: typing.Union[float, int] = None, name: str = 'Elevation [m]') pyvista.core.pointset.PolyData #
Reading a raster and returning a mesh
- Parameters
path (str) – Path to the raster, e.g.
path='raster.tif'
nodata_val (Union[float, int]) – Nodata value of the raster, e.g.
nodata_val=9999.0
name (str) – Name of the data array, e.g.
name='Elevation [m]
, default is'Elevation [m]'
- Returns
mesh – PyVista mesh containing the raster values
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
Changed in version 1.1.1: Set nodata value manually if no data value is provided and raster does not contain nodata values
Example
>>> # Loading Libraries and outputting mesh >>> import gemgis as gg >>> polydata = gg.visualization.read_raster(path='raster.tif', nodata_val=9999.0, name='Elevation [m]') >>> polydata Header StructuredGrid Information N Cells 5595201 N Points 5600000 X Bounds 3.236e+07, 3.250e+07 Y Bounds 5.700e+06, 5.800e+06 Z Bounds 0.000e+00, 0.000e+00 Dimensions 2000, 2800, 1 N Arrays 1 Data Arrays Name Field Type N Comp Min Max Elevation [m] Points float32 1 0.000e+00 5.038e+02
See also
convert_to_rgb
Converting bands to RGB values for plotting
drape_array_over_dem
Draping an array of the Digital Elevation Model
- gemgis.visualization.resample_between_well_deviation_points(coordinates: numpy.ndarray) numpy.ndarray #
Resampling between points that define the path of a well
- Parameters
coordinates (np.ndarray) – Nx3 Numpy array containing the X, Y, and Z coordinates that define the path of a well
- Returns
points_resampled – Resampled points along a well
- Return type
np.ndarray
New in version 1.0.x.
- gemgis.visualization.seismic_to_array(seismic_data, cdp_start: Optional[int] = None, cdp_end: Optional[int] = None, max_depth: Optional[Union[int, float]] = None) numpy.ndarray #
Converting seismic data loaded with segysak to a NumPy array
- Parameters
seismic_data (xarray.core.dataset.Dataset) – seismic data loaded with the segysak package
cdp_start (Union[int, type(None)]) – Value for the start CDP number, e.g.
cdp_start=100
, default isNone
cdp_end (Union[int, type(None)]) – Value for the end CDP number, e.g.
cdp_start=200
, default isNone
max_depth (Union[int, float, type(None)]) – Maximum depth of the seismic, e.g.
max_depth=200
, default isNone
- Returns
df_seismic_data_values_reshaped_selected – NumPy array containing the seismic data
- Return type
np.ndarray
New in version 1.0.x.
- gemgis.visualization.seismic_to_mesh(seismic_data, cdp_start: Optional[int] = None, cdp_end: Optional[int] = None, max_depth: Union[int, float] = None, sampling_rate: Optional[int] = None, shift: Union[int, float] = 0, source_crs: Union[str, pyproj.crs.crs.CRS] = None, target_crs: Union[str, pyproj.crs.crs.CRS] = None, cdp_coords=None) pyvista.core.pointset.StructuredGrid #
Converting seismic data loaded with segysak to a PyVista Mesh
- Parameters
seismic_data (xarray.core.dataset.Dataset) – seismic data loaded with the segysak package
cdp_start (Union[int, type(None)]) – Value for the start CDP number, e.g.
cdp_start=100
, default isNone
cdp_end (Union[int, type(None)]) – Value for the end CDP number, e.g.
cdp_start=200
, default isNone
max_depth (Union[int, float, type(None)]) – Maximum depth of the seismic, e.g.
max_depth=200
, default isNone
sampling_rate (Union[int, type(None)]) – Sampling rate of the seismic, e.g.
sampling_rate=2
, default isNone
shift (Union[int, float]) – Shift of the seismic, e.g.
shift=100
, default is0
source_crs (Union[str, pyproj.crs.crs.CRS]) – Source CRS of the seismic, e.g.
source_crs='EPSG:25832'
, default isNone
target_crs (Union[str, pyproj.crs.crs.CRS]) – Target CRS of the seismic, e.g.
target_crs='EPSG:3034'
, default isNone
cdp_coords (Union[int, float, type(None)]) – CDP coordinates of the seismic if no CDP columns are present in the segysak object, default is
None
- Returns
grid – PyVista Structured grid containing the seismic data
- Return type
pv.core.pointset.StructuredGrid
New in version 1.0.x.
- gemgis.visualization.show_well_log_along_well(coordinates: numpy.ndarray, dist: numpy.ndarray, values: numpy.ndarray, radius_factor: Union[int, float] = 2) pyvista.core.pointset.PolyData #
Function to return a tube representing well log values along a well path
- Parameters
coordinates (np.ndarray) – Nx3 Numpy array containing the X, Y, and Z coordinates that define the path of a well
dist (np.ndarray) – np.ndarray containing the measured depths (MD) of values along the well path
values (np.ndarray) – np.ndarray containing the measured well log values along the well path
radius_factor (int, float) – Radius factor to adjust the diameter of the tube, e.g.
radius_factor=2
, default is2
- Returns
tube_along_spline – PyVista PolyData Pointset representing the the measured well log values along the well path
- Return type
pyvista.core.pointset.PolyData
New in version 1.0.x.
gemgis.web module#
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
GemGIS is a Python-based, open-source spatial data processing library. It is capable of preprocessing spatial data such as vector data raster data, data obtained from online services and many more data formats. GemGIS wraps and extends the functionality of packages known to the geo-community such as GeoPandas, Rasterio, OWSLib, Shapely, PyVista, Pandas, and NumPy.
GemGIS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
GemGIS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License (LICENSE) for more details.
- gemgis.web.create_request(wcs_url: str, version: str, identifier: str, form: str, extent: List[Union[int, float]], name: str = 'test.tif') str #
Creating URL to request data from WCS Server
- Parameters
wcs_url (str) – Url of the WCS server, e.g.
url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm'
version (str) – Version number of the WCS as string, e.g.
version='2.0.1'
identifier (str) – Name of the layer, e.g.
identifier='nw_dgm'
form (str) – Format of the layer, e.g.
form='image/tiff'
extent (List[Union[float,int]]) – Extent of the tile to be downloaded, size may be restricted by server, e.g.
extent=[0, 972, 0, 1069]
name (str) – Name of file, e.g.
name='tile1.tif'
, default is'test.tif'
- Returns
url – Url for the WCS request
- Return type
str
New in version 1.0.x.
Example
>>> # Loading Libraries and WCS Service >>> import gemgis as gg >>> wcs = gg.web.load_wms(url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm') >>> wcs <owslib.coverage.wcs201.WebCoverageService_2_0_1 at 0x27fc64783d0>
>>> # Creating Request for WCS Service >>> url = gg.web.create_request(url=wcs.url, version=wcs.version, identifier='nw_dgm', form='image/tiff', extent=[0, 1000, 0, 1000], name='test.tif'])
See also
load_wcs
Load WCS Service
load_as_file
Download WCS data file
load_as_files
Download WCS data files
- gemgis.web.load_as_array(url: str, layer: str, style: str, crs: Union[str, dict], bbox: List[Union[int, float]], size: List[int], filetype: str, transparent: bool = True, save_image: bool = False, path: str = None, overwrite_file: bool = False, create_directory: bool = False) numpy.ndarray #
Loading a portion of a WMS as array
- Parameters
url (str) – Link of the WMS Service, e.g.
url='https://ows.terrestris.de/osm/service?'
layer (str) – Name of layer to be requested, e.g.
layer='OSM-WMS'
style (str) – Name of style of the layer, e.g.
style='default'
crs (str) – String or dict containing the CRS, e.g.
crs='EPSG:4647'
bbox (List[Union[float,int]]) – List of bounding box coordinates, e.g.
bbox=[0, 972, 0, 1069]
size (List[int]) – List of x and y values defining the size of the image, e.g.
size=[1000,1000]
filetype (str) – String of the image type to be downloaded, e.g. ‘filetype=’image/png’``
transparent (bool) – Variable if layer is transparent. Options include:
True
orFalse
, default set toTrue
save_image (bool) – Variable to save image. Options include:
True
orFalse
, default set toFalse
path (str) – Path and file name of the file to be saved, e.g.
path=map.tif
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
wms_array – OWSlib map object loaded as np.ndarray
- Return type
np.ndarray
New in version 1.0.x.
Example
>>> # Loading Libraries and WMS Service as array >>> import gemgis as gg >>> wms_map = gg.web.load_as_array(url='https://ows.terrestris.de/osm/service?', layer='OSM-WMS', style='default', crs='EPSG:4647', bbox=[32286000,32328000, 5620000,5648000], size=[4200, 2800], filetype='image/png') >>> wms_map array([[[0.8039216 , 0.7647059 , 0.65882355], [0.85882354, 0.8784314 , 0.6627451 ], [0.87058824, 0.91764706, 0.6666667 ], ..., [0.78431374, 0.7647059 , 0.65882355], [0.8862745 , 0.9019608 , 0.81960785], [0.9529412 , 0.93333334, 0.9019608 ]]], dtype=float32)
See also
load_wms
Load WMS Service
load_as_map
Load Map from WMS Service
- gemgis.web.load_as_file(url: str, path: str, overwrite_file: bool = False, create_directory: bool = False)#
Executing WCS request and downloading file into specified folder
- Parameters
url (str) – Url for request
path (str) – Path where file is saved, e.g.
path='tile.tif'
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
New in version 1.0.x.
Example
>>> # Loading Libraries and WCS Service >>> import gemgis as gg >>> wcs = gg.web.load_wms(url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm') >>> wcs <owslib.coverage.wcs201.WebCoverageService_2_0_1 at 0x27fc64783d0>
>>> # Creating Request for WCS Service >>> url = gg.web.create_request(url=wcs.url, version=wcs.version, identifier='nw_dgm', form='image/tiff', extent=[0, 1000, 0, 1000], name='test.tif'])
>>> # Downloading file from WCS Service >>> gg.web.load_as_file(url=url, path='tile.tif')
See also
load_wcs
Load WCS Service
create_request
Create request for WCS
load_as_files
Download WCS data files
- gemgis.web.load_as_files(wcs_url: str, version: str, identifier: str, form: str, extent: List[Union[int, float]], size: int, path: str = '', create_directory: bool = False)#
Executing WCS requests and downloading files into specified folder
- Parameters
wcs_url (str) – Url of the WCS server, e.g.
url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm'
version (str) – Version number of the WCS as string, e.g.
version='2.0.1'
identifier (str) – Name of the layer, e.g.
identifier='nw_dgm'
form (str) – Format of the layer, e.g.
form='image/tiff'
extent (List[Union[float,int]]) – Extent of the tile to be downloaded, size may be restricted by server, e.g.
extent=[0, 972, 0, 1069]
size (int) – Size of the quadratic tile that is downloaded, e.g.
size=2000
path (str) – Path where the file is going to be downloaded, e.g.
name='tile1'
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
New in version 1.0.x.
Example
>>> # Loading Libraries and WCS Service >>> import gemgis as gg >>> wcs = gg.web.load_wms(url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm') >>> wcs <owslib.coverage.wcs201.WebCoverageService_2_0_1 at 0x27fc64783d0>
>>> # Downloading files from WCS Service >>> gg.web.load_as_files(wcs_url=wcs.url, version=wcs.version, form='image/tiff', extent=[0, 10000, 0, 10000], size=2000, path='tile.tif')
See also
load_wcs
Load WCS Service
create_request
Create request for WCS
load_as_file
Download WCS data file
- gemgis.web.load_as_gpd(url: str, typename: str = None, outputformat: str = None) geopandas.geodataframe.GeoDataFrame #
Requesting data from a WFS Service
- Parameters
url (str) – URL of the Web Feature Service, e.g.
url="https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&"
typename (str) – Name of the feature layer, e.g.
typename='iwan:L383'
, default isNone
outputformat (str) – Output format of the feature layer, e.g.
outputformat='xml/gml2'
, default isNone
- Returns
feature – GeoDataFrame containing the feature data of the WFS Service
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and WFS Service as GeoDataFrame >>> import gemgis as gg >>> wfs = gg.web.load_as_gpd(url="https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&") >>> wfs gml_id OBJECTID ID SURVEYNAME ARCHIV MESSJAHR OPERATOR OP_NACHFOL MESSFIRMA MESSPUNKTE UP_DATE geometry 0 1541 1541 112 Jemgum 2007 0127494 2007 GdF Produktion Exploration Deutschland GmbH Neptune Energy Deutschland GmbH Geophysik und Geotechnik Leipzig GmbH 1340 2020-01-20T00:00:00+01:00 MULTIPOLYGON (((32395246.839 5907777.660, 3239...
See also
load_wfs
Load WFS Service
- gemgis.web.load_as_map(url: str, layer: str, style: str, crs: Union[str, dict], bbox: List[Union[int, float]], size: List[int], filetype: str, transparent: bool = True, save_image: bool = False, path: str = None, overwrite_file: bool = False, create_directory: bool = False)#
Loading a portion of a WMS as array
- Parameters
url (str) – Link of the WMS Service, e.g.
url='https://ows.terrestris.de/osm/service?'
layer (str) – Name of layer to be requested, e.g.
layer='OSM-WMS'
style (str) – Name of style of the layer, e.g.
style='default'
crs (str) – String or dict containing the CRS, e.g.
crs='EPSG:4647'
bbox (List[Union[float,int]]) – List of bounding box coordinates, e.g.
bbox=[0, 972, 0, 1069]
size (List[int]) – List of x and y values defining the size of the image, e.g.
size=[1000,1000]
filetype (str) – String of the image type to be downloaded, e.g.
filetype='image/png'
transparent (bool) – Variable if layer is transparent. Options include:
True
orFalse
, default set toTrue
save_image (bool) – Variable to save image. Options include:
True
orFalse
, default set toFalse
path (str) – Path and file name of the file to be saved, e.g.
path=map.tif
overwrite_file (bool) – Variable to overwrite an already existing file. Options include:
True
orFalse
, default set toFalse
create_directory (bool) – Variable to create a new directory of directory does not exist Options include:
True
orFalse
, default set toFalse
- Returns
wms_map – OWSlib map object
- Return type
owslib.util.ResponseWrapper
New in version 1.0.x.
Example
>>> # Loading Libraries and WMS Service as Map >>> import gemgis as gg >>> wms_map = gg.web.load_as_map(url='https://ows.terrestris.de/osm/service?', layer='OSM-WMS', style='default', crs='EPSG:4647', bbox=[32286000,32328000, 5620000,5648000], size=[4200, 2800], filetype='image/png') >>> wms_map <owslib.util.ResponseWrapper at 0x261d348cc10>
See also
load_wms
Load WMS Service
load_as_array
Load Map as array from WMS Service
- gemgis.web.load_wcs(url: str)#
Loading Web Coverage Service
- Parameters
url (str) – Link of the Web Coverage Service, e.g.
url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm'
- Returns
wcs – OWSLib Web Coverage Object
- Return type
owslib.coverage.wcs201.WebCoverageService_2_0_1
New in version 1.0.x.
Example
>>> # Loading Libraries and WCS Service >>> import gemgis as gg >>> wcs = gg.web.load_wms(url='https://www.wcs.nrw.de/geobasis/wcs_nw_dgm') >>> wcs <owslib.coverage.wcs201.WebCoverageService_2_0_1 at 0x27fc64783d0>
See also
create_request
Create request for WCS
load_as_file
Download WCS data file
load_as_files
Download WCS data files
- gemgis.web.load_wfs(url: str)#
Loading a WFS Service by URL
- Parameters
url (str) – Link of the WFS Service, e.g.
url="https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&"
- Returns
wfs – OWSLib Feature object
- Return type
owslib.feature.wfs100.WebFeatureService_1_0_0
New in version 1.0.x.
Example
>>> # Loading Libraries and WFS Service >>> import gemgis as gg >>> wfs = gg.web.load_wfs(url="https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&") >>> wfs <owslib.feature.wfs100.WebFeatureService_1_0_0 at 0x19260e21340>
See also
load_as_gpd
Load information of a WFS Service as GeoDataFrame
- gemgis.web.load_wms(url: str)#
Loading a WMS Service by URL
- Parameters
url (str) – Link of the WMS Service, e.g.
url='https://ows.terrestris.de/osm/service?'
- Returns
wms – OWSLib WebMapService Object
- Return type
owslib.map.wms111.WebMapService
New in version 1.0.x.
Example
>>> # Loading Libraries and WMS Service >>> import gemgis as gg >>> wms = gg.web.load_wms(url='https://ows.terrestris.de/osm/service?') >>> wms <owslib.map.wms111.WebMapService_1_1_1 at 0x1c434eb6370>
See also
load_as_map
Load Map from WMS Service
load_as_array
Load Map as array from WMS Service
Module contents#
Top-level package for GemGIS.