Commit 34f44a30 authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

The rasterio dependency is now optional.


Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 3c738358
Pipeline #5527 passed with stage
in 4 minutes and 16 seconds
...@@ -66,7 +66,7 @@ test_py_tools_ds_install: ...@@ -66,7 +66,7 @@ test_py_tools_ds_install:
- conda config --set channel_priority strict # otherwise gdal or libgdal may be installed from defaults channel - conda config --set channel_priority strict # otherwise gdal or libgdal may be installed from defaults channel
# resolve some requirements with conda # resolve some requirements with conda
- conda install --yes -q -c conda-forge numpy gdal pyproj rasterio shapely geopandas - conda install --yes -q -c conda-forge numpy gdal pyproj shapely geopandas
# run installer # run installer
- python setup.py install - python setup.py install
......
...@@ -62,7 +62,7 @@ Using conda_, the recommended approach is: ...@@ -62,7 +62,7 @@ Using conda_, the recommended approach is:
# create virtual environment for py_tools_ds, this is optional # create virtual environment for py_tools_ds, this is optional
conda create -y -q --name py_tools_ds python=3 conda create -y -q --name py_tools_ds python=3
source activate py_tools_ds source activate py_tools_ds
conda install -c conda-forge numpy gdal pyproj rasterio shapely pandas conda install -c conda-forge numpy gdal pyproj shapely pandas
Then install py_tools_ds using the pip installer: Then install py_tools_ds using the pip installer:
......
...@@ -24,7 +24,6 @@ requirements: ...@@ -24,7 +24,6 @@ requirements:
- python - python
- numpy - numpy
- gdal - gdal
- rasterio
- pyproj - pyproj
- geopandas - geopandas
- six - six
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
import numpy as np import numpy as np
import warnings import warnings
import multiprocessing import multiprocessing
from pkgutil import find_loader
# custom # custom
try: try:
...@@ -44,9 +45,9 @@ from ...compatibility.gdal import get_gdal_func ...@@ -44,9 +45,9 @@ from ...compatibility.gdal import get_gdal_func
__author__ = "Daniel Scheffler" __author__ = "Daniel Scheffler"
def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=None, outUL=None, out_res=None, def warp_ndarray_rasterio(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=None, outUL=None, out_res=None,
out_extent=None, out_dtype=None, rsp_alg=0, in_nodata=None, out_nodata=None, out_extent=None, out_dtype=None, rsp_alg=0, in_nodata=None, out_nodata=None,
outExtent_within=True): # pragma: no cover outExtent_within=True): # pragma: no cover
"""Reproject / warp a numpy array with given geo information to target coordinate system. """Reproject / warp a numpy array with given geo information to target coordinate system.
:param ndarray: numpy.ndarray [rows,cols,bands] :param ndarray: numpy.ndarray [rows,cols,bands]
...@@ -71,6 +72,11 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N ...@@ -71,6 +72,11 @@ def warp_ndarray_OLD(ndarray, in_gt, in_prj, out_prj, out_gt=None, outRowsCols=N
:return out_gt: warped gdal GeoTransform :return out_gt: warped gdal GeoTransform
:return out_prj: warped projection as WKT string :return out_prj: warped projection as WKT string
""" """
if not find_loader('rasterio'):
raise ImportError('This function requires rasterio. You need to install it manually '
'(conda install -c conda-forge rasterio). It is not automatically installed.')
# NOTE: rasterio seems to increase the number of objects with static TLS # NOTE: rasterio seems to increase the number of objects with static TLS
# There is a maximum number and if this is exceeded an ImportError is raised: # There is a maximum number and if this is exceeded an ImportError is raised:
# ImportError: dlopen: cannot load any more object with static TLS # ImportError: dlopen: cannot load any more object with static TLS
......
...@@ -3,7 +3,6 @@ kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file ...@@ -3,7 +3,6 @@ kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file
numpy numpy
shapely shapely
six six
rasterio
pandas pandas
geopandas geopandas
pyproj pyproj
......
...@@ -36,7 +36,7 @@ version = {} ...@@ -36,7 +36,7 @@ version = {}
with open("py_tools_ds/version.py") as version_file: with open("py_tools_ds/version.py") as version_file:
exec(version_file.read(), version) exec(version_file.read(), version)
requirements = ['gdal', 'numpy', 'shapely', 'six', 'rasterio', 'pandas', 'geopandas', 'pyproj', 'spectral'] requirements = ['gdal', 'numpy', 'shapely', 'six', 'pandas', 'geopandas', 'pyproj', 'spectral']
setup_requirements = [] # TODO(danschef): put setup requirements (distutils extensions, etc.) here setup_requirements = [] # TODO(danschef): put setup requirements (distutils extensions, etc.) here
test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose"] test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutput", "rednose"]
...@@ -68,8 +68,10 @@ setup( ...@@ -68,8 +68,10 @@ setup(
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
], ],
test_suite='tests', test_suite='tests',
tests_require=test_requirements, tests_require=test_requirements,
setup_requires=setup_requirements setup_requires=setup_requirements,
extras_require={'rio_reproject': ["rasterio"]}
) )
...@@ -10,7 +10,6 @@ dependencies: ...@@ -10,7 +10,6 @@ dependencies:
- gdal - gdal
- conda-forge::libgdal # force to use conda-forge for libgdal to avoid package version incompatiblies due to mixed channels (libkea.so.1.4.7: cannot open shared object file: No such file or directory) - conda-forge::libgdal # force to use conda-forge for libgdal to avoid package version incompatiblies due to mixed channels (libkea.so.1.4.7: cannot open shared object file: No such file or directory)
# - kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file or directory (not needed as long as libgdal and gdal are conda-forge packages) # - kealib # fix for libkea.so.1.4.7: cannot open shared object file: No such file or directory (not needed as long as libgdal and gdal are conda-forge packages)
- rasterio
- pyproj - pyproj
- geopandas - geopandas
- pip: - pip:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment