GemGIS API Reference
Contents
GemGIS API Reference#
The API reference provides an overview of all functions and methods implemented in GemGIS.
Vector#
The following sections provide an overview of the methods implemented in the GemGIS Vector module.
Extracting Coordinates from GeoDataFrames#
The following methods are used to extract X and Y coordinates or X, Y, and Z coordinates from GeoDataFrames or Shapely Base Geometries for further usage.
|
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 |
|
Extracting the coordinates of Shapely LineStrings within a GeoDataFrame and storing the X and Y coordinates in lists per LineString |
|
Extracting X and Y coordinates from a GeoDataFrame (LineStrings) and returning a GeoDataFrame with X and Y coordinates as additional columns |
|
Extracting X and Y coordinates from a GeoDataFrame (Points) and returning a GeoDataFrame with X and Y coordinates as additional columns |
|
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 |
|
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 |
|
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 |
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely Points with Z components |
|
|
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely LineStrings with Z components |
|
Extracting X, Y, and Z coordinates from a GeoDataFrame containing Shapely Polygons with Z components |
Extracting Coordinates and Intersections from GeoDataFrames/Shapely Polygons#
The following methods are used to extract coordinates and intersections from GeoDataFrames containing Shapely Polygons or from single Shapely Polygons or multiple Shapely Polygons.
Calculating the intersections between Polygons; the table must be sorted by stratigraphic age |
|
Calculating the intersection between to Shapely Polygons |
|
Calculating the intersections between one polygon and a list of polygons |
|
Calculating the intersections between a list of Polygons |
Calculating and extracting coordinates from cross sections#
The following methods are used to calculate and extract coordinates from cross sections where data was stored as Shape Files and is now loaded as GeoDataFrames.
|
Extracting coordinates of interfaces digitized on a cross section |
Extracting X, Y, and Z coordinates from cross sections and digitized interfaces |
|
|
Calculating the coordinates for one point digitized on a cross section provided as Shapely LineString |
|
Calculating the coordinates of vertices for a LineString on a straight cross section provided as Shapely LineString |
|
Calculating the coordinates of vertices for LineStrings on a straight cross section provided as Shapely LineString |
|
Extracting coordinates of interfaces digitized on a cross section |
Calculating and extracting angles from cross sections and maps#
The following methods are used to calculate and extract angles from cross sections.
|
Calculating the angle of a LineString to the vertical |
Calculating the azimuth for an orientation Geodataframe represented by LineStrings |
|
|
Function to calculate the strike direction of a straight Shapely LineString. |
|
Calculating the strike direction of a LineString with multiple elements |
Calculating the dipping angle of a LineString digitized on a cross section |
|
Calculating the dipping angles of LineStrings digitized on a cross section |
|
|
Calculating the orientation of a LineString on a bent cross section provided as Shapely LineString |
Calculating the orientation for one LineString on one cross sections |
|
|
Calculating orientations from a cross sections using multiple LineStrings |
Calculating orientations digitized from cross sections |
|
Calculating orientations from LineStrings |
|
Calculating orientations based on LineStrings representing strike lines |
|
|
Calculating the orientation for a three point problem |
Exploding Geometries#
The following methods are used to explode geometries for further usage in GemGIS
|
Exploding a LineString to its vertices, also works for LineStrings with Z components |
Separating a LineString into its single elements and returning a list of LineStrings representing these elements, also works for LineStrings with Z components |
|
Exploding a MultiLineString into a list of LineStrings |
|
Exploding Shapely MultiLineStrings stored in a GeoDataFrame to Shapely LineStrings |
|
|
Exploding Shapely Polygon to list of Points |
Converting a GeoDataFrame containing elements of geom_type Polygons to a GeoDataFrame with LineStrings |
|
Exploding a Shapely Geometry Collection to a List of Base Geometries |
|
Exploding Shapely Geometry Collections stored in GeoDataFrames to different Shapely Base Geometries |
Removing Points within Buffers#
The following methods are used to remove Points within Buffers. This can be used to remove interface points in the vicinity of faults.
Removing object from a buffered object by providing a distance |
|
Removing objects from a buffered object by providing a distance |
|
Function to create a buffer around a GeoDataFrame containing fault data and removing interface points that are located within this buffer |
Vector Methods for Raster Data#
The following methods are used to work with raster data
|
Interpolating a raster/digital elevation model from point or line Shape file |
Working with GPX Data#
The following methods are used to work with GPX data
|
Loading a GPX file as collection |
|
Loading a GPX file as dict |
|
Loading a GPX file as Shapely Geometry |
Miscellaneous vector data methods#
The following methods are further vector data methods used in GemGIS
Calculating the minimal distance between two LineStrings |
|
Calculating the midpoint of a LineString with two vertices |
|
Calculating the midpoints of LineStrings with two vertices each |
|
|
Clipping vector data contained in a GeoDataFrame to a provided bounding box/extent |
|
Clipping vector data contained in a GeoDataFrame to a provided bounding box/extent |
|
Creating a rectangular polygon from the provided bounding box values, with counter-clockwise order by default. |
|
Creating a buffer around a Shapely LineString or a Point |
Creating a unified buffer around Shapely LineStrings or Points |
|
Creating a LineString object from a GeoDataFrame containing surface points at a given altitude and for a given formation |
|
Create LineString from an array or GeoDataFrame containing X, Y, and Z coordinates of points. |
|
Creating LineStrings from Points |
|
Creating LineStrings from PyVista Contour Lines and save them as list or GeoDataFrame |
|
Creating LineStrings from a GeoDataFrame containing X, Y, and Z coordinates of vertices of multiple LineStrings |
|
Extracting faces from PyVista PolyData as Shapely Polygons |
|
|
Unifying adjacent LineStrings to form LineStrings with multiple vertices |
|
Unifying adjacent triangular polygons to form larger objects |
Special Methods#
The following methods are special methods used in GemGIS
|
Checking and setting the dtypes of the input data GeoDataFrame |
|
Sorting a GeoDataFrame by a provided list of Stratigraphic Units |
Subtracting Shapely geometry objects from each other and returning the left over object |
|
|
Function to create one hexagon |
|
Function to create a grid of hexagons based on a GeoDataFrame containing Polygons and a radius provided for the single hexagons |
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) |
Raster#
The following sections provide an overview of the methods implemented in the GemGIS Raster module.
Raster Calculations#
The following methods are used to perform calculations on rasters
|
Calculating the aspect based on a digital elevation model/raster |
|
Calculating the difference between two rasters |
|
Calculating Hillshades based on digital elevation model/raster |
|
Calculating the slope based on digital elevation model/raster |
Sampling from a Raster#
The following methods are used to sample values from a raster
|
Sampling the value of a np.ndarray at a given point and given the arrays true extent |
|
Sampling the value of a rasterio object at a given point within the extent of the raster |
|
Sampling interfaces from a raster |
|
Sampling orientations from a raster |
|
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 |
Reading different raster formats#
The following methods are used to read different raster formats into Python
|
Function to read GoCAD .asc files |
|
Function to read Leapfrog .msh files - https://help.leapfrog3d.com/Geo/4.3/en-GB/Content/meshes/meshes.htm |
|
Function to read GoCAD .ts files |
|
Reading Petrel ZMAP Files |
Miscellaneous raster data methods#
The following methods are further raster data methods used in GemGIS
|
Clipping a rasterio raster or np.ndarray by a given extent |
|
Clipping/masking a rasterio raster or np.ndarray by a given shapely Polygon |
|
Retrieving the file paths of the tiles to load and to process them later |
Extracting contour lines from raster with a provided interval. |
|
|
Merging downloaded tiles to mosaic |
|
Reprojecting a raster into different CRS |
|
Rescaling raster to the size of another raster |
|
Resizing raster to given dimensions |
|
Saving a np.array as tif file |
Visualization#
The following sections provide an overview of the methods implemented in the GemGIS Visualization module.
Creating PolyData and Grid Data from GeoDataFrames, Rasters, and GemPy Models#
The following methods are used to create PolyData from various input data formats.
Extracting the depth values of the vertices and add them as scalars to the mesh |
|
Creating depth map of model surfaces, adapted from https://github.com/cgre-aachen/gempy/blob/20550fffdd1ccb3c6a9a402bc162e7eed3dd7352/gempy/plot/vista.py#L440-L477 |
|
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 |
|
Creating a temperature map for a surface at depth taking the topography into account |
|
Creating a delaunay triangulated mesh from surface contour lines |
|
|
Plotting the dem in 3D with PyVista |
Creating lines with z-component (LineString Z) |
|
Creating lines with z-component for the plotting with PyVista |
|
Creating a PyVista Mesh from one cross section |
|
Creating PyVista Meshes from multiple cross section |
|
Plotting earthquake hypocenters with PyVista |
|
Plotting points in 3D with PyVista |
|
Converting loaded DXF object to PyVista PolyData |
|
Converting loaded Leapfrog mesh to PyVista PolyData |
|
Converting loaded GoCAD mesh to PyVista PolyData |
|
Converting loaded ASC object to PyVista StructuredGrid |
|
Converting loaded ZMAP object to PyVista StructuredGrid |
Working with Boreholes#
The following methods are used to work with boreholes in GemGIS.
Adding additional row to each borehole for further processing for 3D visualization |
|
Create labels for borehole plots. |
|
Creating a tube from a line for the 3D visualization of boreholes |
|
Creating PyVista Tubes for plotting boreholes in 3D |
|
Plotting boreholes in 3D |
|
Creating a line set from a Pandas DataFrame |
|
Creating Pandas DataFrame containing parameters to create 3D boreholes |
|
Plotting boreholes in 3D |
|
Grouping Borehole DataFrame by Index |
|
|
Resampling between points that define the path of a well |
Function to return a tube representing well log values along a well path |
Miscellaneous visualization methods#
The following methods are further visualization methods used in GemGIS.
|
Calculating the plunge vector of a borehole section |
Clipping seismic data loaded with segysak to CDP defined start and end CDP values |
|
Converting array values to RGB values |
|
Creating grid and texture to drape array over a digital elevation model |
|
Returning the Batlow cmap from https://github.com/callumrollo/cmcrameri/blob/master/cmcrameri/cmaps/batlow.txt |
|
|
Method to get the right color list depending on the type of plot. |
Getting the geological map of a GemPy Model draped over the topography as mesh. |
|
Returning the Petrel cmap |
|
Returning the closest point on the spline a given a length along a spline. |
|
Returning the seismic cmap from https://github.com/lperozzi/Seismic_colormaps/blob/master/colormaps.py |
|
Fitting a plane through the hypocenters of earthquakes using Eigenvector analysis |
|
|
Plotting Input Data |
Plotting orientation values of a GeoDataFrame with mplstereonet |
|
Creating PyVista PolyLine from points |
|
|
Reading a raster and returning a mesh |
|
Converting seismic data loaded with segysak to a NumPy array |
|
Converting seismic data loaded with segysak to a PyVista Mesh |
Utils#
The following sections provide an overview of the methods implemented in the GemGIS Utils module.
Miscellaneous utils methods#
The following methods are further visualization methods used in GemGIS.
|
Replacing lith block IDs with physical properties |
|
Building a style dict based on extracted style classes |
|
Parsing a QGIS style file to retrieve surface color values |
|
Loading surface colors from a QML file and storing the color values as list to be displayed with GeoPandas plots |
Creating GemPy surface color dict from a QML file |
|
|
Function to interpolate strike lines |
Creating the number of isopoints to further interpolate strike lines |
|
Converting a location dict to a GeoDataFrame |
|
|
Converting a GeoDataFrame into a Pandas DataFrame ready to be read in for GemPy |
Function to convert vertices of a PyVista Mesh to Petrel Points with Attributes |
|
Creating Shapely Polygon from bounding box coordinates |
|
|
Function to filter and sort the resulting well tops |
|
Function to write data to ZMAP Grid, This code is heavily inspired by https://github.com/abduhbm/zmapio |
|
Function to extract a meshgrid of values from a PyVista mesh |
Obtaining coordinates of a given city |
|
|
Obtaining coordinates for one city or a list of given cities. |
Function to return the index of the nearest neighbor for a given point Y |
|
|
Creating a list containing a dict with keys and values to clip a raster |
|
Interpolating strike lines to calculate orientations |
Function to return the depth of multiple surfaces in one well using PyVista ray tracing |
|
|
Function to return the depth of one surface in one well using PyVista ray tracing |
|
Reading CSV files as GeoDataFrame |
|
Function to save ZMAP Grid information to file |
|
Setting the extent for a model |
|
Setting the resolution for a model |
Adding the number of Interfaces and Orientations to the GemPy Surface dataframe |
|
|
Converting custom sections stored in Shape files to GemPy section_dicts |
Transforming coordinates of GeoPy Location |
Web#
The following sections provide an overview of the methods implemented in the GemGIS Web module.
|
Creating URL to request data from WCS Server |
|
Loading a portion of a WMS as array |
|
Executing WCS request and downloading file into specified folder |
|
Executing WCS requests and downloading files into specified folder |
|
Requesting data from a WFS Service |
|
Loading a portion of a WMS as array |
|
Loading Web Coverage Service |
|
Loading a WFS Service by URL |
|
Loading a WMS Service by URL |
Miscellaneous#
The following sections provide an overview of the methods implemented in the GemGIS Misc module.
This function is used to extract the name, coordinates and depths, of one page with one well provided by the Geological Survey NRW. |
|
|
Function to create a dataframe with coordinates and meta data of the different boreholes |
|
Function to retrieve the stratigraphic data from borehole logs |
|
Function to create a dataframe with coordinates and the stratigraphy of the different boreholes |
Loading formations for extraction of borehole data |
|
|
Load PDF file containing borehole data. |
|
Loading symbols for extraction of borehole data |
Postprocessing#
The following section provides an overview of the methods implemented in the GemGIS postprocessing module.
|
Calculating dip and azimuth values for a mesh and setting them as scalars for subsequent plotting |
Creating a list of attribute dicts |
|
Creating Subelement |
|
|
Creating symbol entry |
Cropping GemPy solutions block to topography |
|
Extracting a borehole at a provided location from a recalculated GemPy Model |
|
Extracting the geological map as GeoDataFrame |
|
Extracting orientations (dip and azimuth) from PyVista Mesh |
|
|
Function to save the model parameters to files |
Creating and saving a QGIS Style File/QML File based on a GeoDataFrame |
|
Clip fault of a GemPy model. |
|
|
Create PyVista plane from GemPy interface and orientations DataFrames. |
Translate clipping plane. |
Download GemGIS Data#
The following section provides an overview of the methods implemented in the GemGIS module that downloads the tutorial data.
Create pooch class to fetch files from a website. |
|
Download the GemGIS data for each tutorial. |