Skip to content

Commit

Permalink
Merge pull request #304 from cgre-aachen/dev_gemgis3
Browse files Browse the repository at this point in the history
Dev gemgis3
  • Loading branch information
AlexanderJuestel authored Oct 3, 2023
2 parents 5ecbc45 + 9a95aeb commit bfbd01e
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 36 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
.idea/*

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down Expand Up @@ -239,3 +240,5 @@ examples/models/data/*
examples/notebooks/data/*
gemgis/__pycache__
__pycache__

_version_generated.py
4 changes: 3 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ include README.md
include requirements.txt
include requirements_dev.txt

recursive-exclude * __pycache__
recursive-exclude * __pycache__

exclude .git/* .idea/*
10 changes: 7 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
copyright = "2020–2023, GemGIS Developers"
author = 'Alexander Juestel'

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


# -- GemGIS configuration ---------------------------------------------------
import os
Expand All @@ -29,6 +27,12 @@
sys.path.insert(0, os.path.abspath("../gemgis/"))
sys.path.insert(0, os.path.abspath("../../gemgis/"))

# The full version, including alpha/beta/rc tags

import gemgis as gg

version = gg.__version__

# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
Expand Down
Binary file added docs/getting_started/images/tutorial71_cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2211,6 +2211,7 @@
}
],
"metadata": {
"hide_input": false,
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
Expand All @@ -2226,7 +2227,36 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
"version": "3.8.5"
},
"varInspector": {
"cols": {
"lenName": 16,
"lenType": 16,
"lenVar": 40
},
"kernels_config": {
"python": {
"delete_cmd_postfix": "",
"delete_cmd_prefix": "del ",
"library": "var_list.py",
"varRefreshCmd": "print(var_dic_list())"
},
"r": {
"delete_cmd_postfix": ") ",
"delete_cmd_prefix": "rm(",
"library": "var_list.r",
"varRefreshCmd": "cat(var_dic_list()) "
}
},
"types_to_exclude": [
"module",
"function",
"builtin_function_or_method",
"instance",
"_Feature"
],
"window_display": false
}
},
"nbformat": 4,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"source": [
"# 71 Opening Rasters from OpenFileGDB\n",
"\n",
"This notebook illustrates how to open rasters that are stored in OpenFileGDBs. Currently, QGIS can open rasters from OpenFileGDBs since version 3.32. GeoPandas and the underlying fiona package are capable of opening vector files from OpenFileGDBs. It is not planned to support raster files (https://github.com/geopandas/geopandas/issues/2793). It is not planned to implement that feature into rasterio either (https://github.com/rasterio/rasterio/discussions/2914). Therefore, the decision was made to implement the functionality to open rasters from OpenFileGDBs directly using the `gdal` package. "
"This notebook illustrates how to open rasters that are stored in OpenFileGDBs. Currently, QGIS can open rasters from OpenFileGDBs since version 3.32. GeoPandas and the underlying fiona package are capable of opening vector files from OpenFileGDBs. It is not planned to support raster files (https://github.com/geopandas/geopandas/issues/2793). It is not planned to implement that feature into rasterio either (https://github.com/rasterio/rasterio/discussions/2914). Therefore, the decision was made to implement the functionality to open rasters from OpenFileGDBs directly using the `gdal` package. \n",
"\n",
"<img src=\"../images/tutorial71_cover.png\">"
]
},
{
Expand Down
1 change: 1 addition & 0 deletions environment_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ dependencies:
- sphinx_automodapi
- sphinx_numfig
- numpydoc
- build
2 changes: 0 additions & 2 deletions gemgis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@

__version_date__ = '2023-09-23'

__version__ = '1.1.1'

__changelog__ = """What is new in version 1.1.0:
Expand Down
12 changes: 10 additions & 2 deletions gemgis/download_gemgis_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,17 @@ def create_pooch(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: ''
target : str, default: ``''``
The path to the local data storage folder, e.g. ``target='Documents/gemgis/'``.
Returns
_______
pooch.core.Pooch
Pooch class.
See also
________
download_tutorial_data: Download the GemGIS data for each tutorial.
"""
try:
import pooch
Expand All @@ -67,11 +71,15 @@ def download_tutorial_data(filename: str,
__________
filename : str
File name to be downloaded by pooch, e.g. ``filename='file.zip'``.
dirpath : str, default: ''
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.
"""
try:
import pooch
Expand Down
29 changes: 12 additions & 17 deletions gemgis/misc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Contributors: Alexander Jüstel, Arthur Endlein Correia, Florian Wellmann, Marius Pischke
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
Expand Down Expand Up @@ -33,23 +33,21 @@

def load_pdf(path: str,
save_as_txt: bool = True) -> str:
"""Function to load pdf containing borehole data
"""
Load PDF file containing borehole data.
Parameters
__________
path : str
Name of the PDF file, e.g. ``path='file.pdf'``
save_as_txt : bool
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`` or ``False``, default set to ``True``
Options include: ``True`` or ``False``.
Returns
_______
page_content : str
Extracted page content from borehole data
str
Extracted page content from borehole data.
.. versionadded:: 1.0.x
Expand All @@ -66,14 +64,11 @@ def load_pdf(path: str,
See Also
________
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
get_stratigraphic_data_df : Getting the stratigraphic data of wells as DataFrame
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.
"""

# Trying to import PyPDF2 but returning error if tqdm is not installed
try:
import PyPDF2
Expand Down
11 changes: 9 additions & 2 deletions gemgis/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -2716,7 +2716,8 @@ def extract_contour_lines_from_raster(raster: Union[rasterio.io.DatasetReader, n
def read_raster_gdb(path: str,
crs: Union[str,
pyproj.crs.crs.CRS,
rasterio.crs.CRS] = None):
rasterio.crs.CRS] = None,
path_out: str = ''):
"""Read Raster from OpenFileGDB.
Parameters
Expand All @@ -2725,6 +2726,8 @@ def read_raster_gdb(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
.. versionadded:: 1.1.1
Expand All @@ -2739,6 +2742,10 @@ def read_raster_gdb(path: str,
if not isinstance(path, str):
raise TypeError('Path to the OpenFileGDB must be provided as string')

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

# Opening Database
ds = gdal.Open(path)

Expand Down Expand Up @@ -2768,7 +2775,7 @@ def read_raster_gdb(path: str,

# Saving raster to file
with rasterio.open(
ds.GetSubDatasets()[i][1].replace(' ', '') + '.tif',
path_out + ds.GetSubDatasets()[i][1].replace(' ', '') + '.tif',
'w',
driver='GTiff',
height=raster.shape[0],
Expand Down
2 changes: 1 addition & 1 deletion gemgis/vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def extract_xy(gdf: gpd.geodataframe.GeoDataFrame,
.. versionchanged:: 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.
be reset. Not resetting the index will cause index errors later on.
Example
_______
Expand Down
8 changes: 7 additions & 1 deletion gemgis/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ def convert_to_rgb(array: np.ndarray) -> np.ndarray:
def drape_array_over_dem(array: np.ndarray,
dem: Union[rasterio.io.DatasetReader, np.ndarray],
extent: List[Union[float, int]] = None,
zmax: Union[float, int] = 1000,
zmax: Union[float, int] = 10000,
resize_array: bool =True):
"""Creating grid and texture to drape array over a digital elevation model
Expand Down Expand Up @@ -834,6 +834,10 @@ def drape_array_over_dem(array: np.ndarray,
.. versionchanged:: 1.1
Function now allows rasters with different sizes and resizes one of the rasters automatically
.. versionchanged:: 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
_______
Expand Down Expand Up @@ -921,10 +925,12 @@ def drape_array_over_dem(array: np.ndarray,

if resize_array:
array = resize(image=array,
preserve_range=True,
output_shape=(dem.shape[0],
dem.shape[1]))
else:
dem = resize(image=dem,
preserve_range=True,
output_shape=(array.shape[0],
array.shape[1]))

Expand Down
13 changes: 8 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ requires = ["setuptools>=68.1.2",
"setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
package-dir = { "" = "gemgis" }

[project]
name = "GemGIS"

Expand All @@ -17,8 +20,8 @@ description = "Spatial data processing for geomodeling"
keywords = ["dataprocessing", "modeling", "geospatial", "geographic-data", "spatial-data", "rasterdata", "vectordata",
"geographic", "geomodeling"]
readme = "README.md"
license = {file = LICENSE}
dynamic = ["Version"]
license = {file = "LICENSE"}
dynamic = ['version']
requires-python = ">=3.8"
classifiers = [
'Development Status :: 5 - Production/Stable',
Expand All @@ -32,9 +35,9 @@ classifiers = [
'Operating System :: OS Independent',
]
dependencies = [
geopandas,
rasterio,
pyvista,
'geopandas',
'rasterio',
'pyvista',
]
[project.urls]
Documentation = 'https://gemgis.readthedocs.io/'
Expand Down
File renamed without changes.

0 comments on commit bfbd01e

Please sign in to comment.