Skip to content

Commit

Permalink
Merge pull request #299 from cgre-aachen/dev_gemgis3
Browse files Browse the repository at this point in the history
GemGIS 1.1.1
  • Loading branch information
AlexanderJuestel authored Sep 23, 2023
2 parents 8bb2c7c + 2038a9f commit 5ecbc45
Show file tree
Hide file tree
Showing 15 changed files with 2,313 additions and 41 deletions.
1 change: 1 addition & 0 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine
pip install -r requirements.txt
- name: Build and publish
env:
TWINE_USERNAME: ${{ secrets.PYPI_USERS }}
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ Furthermore, many [example models](https://gemgis.readthedocs.io/en/latest/getti
<a name="installation"></a>
## Installation
It is recommended to use GemGIS with **python">=3.10"** in a separated environment. The main packages and its dependencies can be installed via the conda-forge channel. GemGIS is then available through PyPi or Conda.
1) `conda install -c conda-forge geopandas">=0.12.2" rasterio">=1.3.4"`
2) `conda install -c conda-forge pyvista">=0.37.0"`
1) `conda install -c conda-forge geopandas">=0.13.2" rasterio">=1.3.8"`
2) `conda install -c conda-forge pyvista">=0.42.1"`
3) `pip install gemgis` / `conda install -c conda-forge gemgis`

Check out the [Installation Page](https://gemgis.readthedocs.io/en/latest/getting_started/installation.html) for more detailed instructions.
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
author = 'Alexander Juestel'

# The full version, including alpha/beta/rc tags
release = '1.1.0'
release = '1.1.1'
version = release

# -- GemGIS configuration ---------------------------------------------------
Expand Down
Binary file added docs/getting_started/images/tutorial70_cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions docs/getting_started/installation.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.. _installation_ref:

Installation (Tested 2023-01-01)
Installation (Tested 2023-09-01)
===========================================================

GemGIS is supported on Python version 3.10. Previous versions are officially not supported.
Expand Down Expand Up @@ -96,15 +96,15 @@ Installing GemGIS's dependencies manually

Two of the main packages that GemGIS is dependent on are `rasterio <https://rasterio.readthedocs.io/en/latest/>`_ and `GeoPandas <https://geopandas.org/>`_. It is recommended to install these packages separately as they both depend on the `GDAL <https://gdal.org/>`_ translator library for raster and vector geospatial data. In addition, many smaller libraries like shaply or fiona will also be installed properly.

Install the latest versions of GeoPandas and Rasterio (as of 2023-01-01). Please mind the quotation marks that are necessary when specifying the version numbers.::
Install the latest versions of GeoPandas and Rasterio (as of 2023-09-01). Please mind the quotation marks that are necessary when specifying the version numbers.::

conda install -c conda-forge geopandas">=0.12.2" rasterio">=1.3.4"
conda install -c conda-forge geopandas">=0.13.2" rasterio">=1.3.8"

.. image:: images/cmd6.png

In order to visualize and work with meshes, the `PyVista <https://docs.pyvista.org/>`_ package is being installed::

conda install -c conda-forge pyvista">=0.37.0"
conda install -c conda-forge pyvista">=0.42."


Installing GemGIS via PyPi
Expand Down
1,634 changes: 1,634 additions & 0 deletions docs/getting_started/tutorial/70_Reprojecting_Seismic_Data.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion docs/getting_started/tutorial/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,6 @@ Each set of functions of GemGIS is collected in a different module. The function
65_displaying_seismic_horizons_and_faults
66_generating_voronoi_polygons
67_rotating_gempy_input_data
68_Creating_Finite_Faults_with_GemGIS
68_Creating_Finite_Faults_with_GemGIS
70_Reprojecting_Seismic_Data
71_Opening_Rasters_From_OpenFileGDB
8 changes: 6 additions & 2 deletions gemgis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@

__affiliations__ = 'CGRE - RWTH Aachen University'

__version_date__ = '2023-08-18'
__version_date__ = '2023-09-23'

__version__ = '1.1.0'
__version__ = '1.1.1'

__changelog__ = """What is new in version 1.1.0:
"""
try:
from ._version_generated import __version__
except ImportError:
__version__ = "unreleased"

from gemgis.gemgis import *
import gemgis.vector as vector
Expand Down
18 changes: 4 additions & 14 deletions gemgis/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1074,21 +1074,11 @@ def clip_fault_of_gempy_model(geo_model,
raise ValueError('Fault is not part of the GemPy geo_model')

# Getting the fault DataFrames
fault_df_interfaces = gp.get_data(geo_model, 'surface_points')[
gp.get_data(geo_model,
'surface_points')['surface'] == fault].reset_index(drop=True)
fault_df_interfaces = geo_model.surface_points.df[
geo_model.surface_points.df['surface'] == fault].reset_index(drop=True)

fault_df_orientations1 = gp.get_data(geo_model,
'orientations',
numeric=False)
fault_df_orientations2 = gp.get_data(geo_model,
'orientations',
numeric=True)

fault_df_orientations = fault_df_orientations1.merge(fault_df_orientations2,
how='inner')

fault_df_orientations = fault_df_orientations[fault_df_orientations['surface'] == fault].reset_index(drop=True)
fault_df_orientations = geo_model.orientations.df[
geo_model.orientations.df['surface'] == fault].reset_index(drop=True)

# Checking that the parameter which is of type string or list of strings
if not isinstance(which, str):
Expand Down
71 changes: 71 additions & 0 deletions gemgis/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2711,3 +2711,74 @@ def extract_contour_lines_from_raster(raster: Union[rasterio.io.DatasetReader, n
gdf_lines['Z'] = values

return gdf_lines


def read_raster_gdb(path: str,
crs: Union[str,
pyproj.crs.crs.CRS,
rasterio.crs.CRS] = None):
"""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.
.. versionadded:: 1.1.1
"""
# Trying to import osgeo but returning error if tqdm is not installed
try:
from osgeo import gdal, osr
except ModuleNotFoundError:
raise ModuleNotFoundError('osgeo package is not installed')

# Checking that the path is of type string
if not isinstance(path, str):
raise TypeError('Path to the OpenFileGDB must be provided as string')

# Opening Database
ds = gdal.Open(path)

# Getting the length of the subsets
len_subdatasets = len(ds.GetSubDatasets())

# Performing workflow for every dataset
for i in range(len_subdatasets):
# Getting the name of the layer
layer = ds.GetSubDatasets()[i][0]
# Opening the raster layer
dataset = gdal.Open(layer)
# Getting the first raster band
raster_band = dataset.GetRasterBand(1)
# Getting raster values as array
raster = raster_band.ReadAsArray()

# Creating CRS from projection or manually
if dataset.GetProjection():
proj = osr.SpatialReference(wkt=dataset.GetProjection())
epsg = proj.GetAttrValue('AUTHORITY', 1)
crs = 'EPSG:' + epsg
else:
if not crs:
raise ValueError(
'Raster does not have a projection, please provide a valid coordinate reference system')

# Saving raster to file
with rasterio.open(
ds.GetSubDatasets()[i][1].replace(' ', '') + '.tif',
'w',
driver='GTiff',
height=raster.shape[0],
width=raster.shape[1],
count=1,
dtype=raster.dtype,
crs=crs,
transform=affine.Affine.from_gdal(*dataset.GetGeoTransform()),
nodata=raster_band.GetNoDataValue()
) as dst:
dst.write(raster, 1)

print(ds.GetSubDatasets()[i][1].replace(' ', '') + '.tif successfully saved to file')
Loading

0 comments on commit 5ecbc45

Please sign in to comment.