diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 45b311c..e0a7a28 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -49,6 +49,7 @@ jobs: python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi + if [ -f requirements_extra.txt ]; then pip install -r requirements_extra.txt; fi - name: Test with pytest ⚙️ run: | make test diff --git a/CHANGES.rst b/CHANGES.rst index 3daef2b..7d240d6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,15 @@ Change History ************** +0.8.5 (unreleased) +================== + +Changes: + +* Update how TIFF files are converted to xarray datasets because `open_rasterio` is deprecated. See issue `239`. +* Remove `GeotiffRasterioConverter` + + 0.8.4 (2023-05-24) ================== diff --git a/birdy/client/converters.py b/birdy/client/converters.py index e0455ba..7471701 100644 --- a/birdy/client/converters.py +++ b/birdy/client/converters.py @@ -250,7 +250,6 @@ def convert(self): # noqa: D102 return IPython.display.Image(self.url) -# TODO: Add test for this. class GeotiffRioxarrayConverter(BaseConverter): # noqa: D101 mimetypes = ["image/tiff; subtype=geotiff"] extensions = ["tiff", "tif"] @@ -263,22 +262,7 @@ def convert(self): # noqa: D102 import xarray # isort: skip import rioxarray # noqa - return xarray.open_rasterio(self.file) - - -# TODO: Add test for this. -class GeotiffRasterioConverter(BaseConverter): # noqa: D101 - mimetypes = ["image/tiff; subtype=geotiff"] - extensions = ["tiff", "tif"] - priority = 2 - - def check_dependencies(self): # noqa: D102 - self._check_import("rasterio") - - def convert(self): # noqa: D102 - import rasterio # isort: skip - - return rasterio.open(self.file).read() + return xarray.open_dataset(self.file, engine="rasterio") # TODO: Add test for this. diff --git a/requirements.txt b/requirements.txt index a2a150a..984cab1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,3 +8,4 @@ packaging python-dateutil>=2.8.1 requests>=2.0 wrapt +pyOpenSSL diff --git a/requirements_extra.txt b/requirements_extra.txt index 4e70f98..4033b8e 100644 --- a/requirements_extra.txt +++ b/requirements_extra.txt @@ -5,5 +5,5 @@ ipython ipywidgets netCDF4 pymetalink -rasterio +xarray rioxarray diff --git a/tests/test_client.py b/tests/test_client.py index 621c75e..6c958b6 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -20,8 +20,6 @@ # 52 north WPS url_52n = "http://geoprocessing.demo.52north.org:8080/wps/WebProcessingService?service=WPS&version=1.0.0&request=GetCapabilities" # noqa: E501 -# flyingpigeon WPS at Ouranos -url_fly = "https://pavics.ouranos.ca/twitcher/ows/proxy/flyingpigeon/wps" @pytest.fixture(scope="module") @@ -70,14 +68,9 @@ def test_52north_offline(): ) -@pytest.mark.online -def test_flyingpigeon(): # noqa: D103 - WPSClient(url_fly) - - def test_flyingpigeon_offline(): # noqa: D103 WPSClient( - url_fly, + "https://test.org", caps_xml=open(resource_file("wps_fly_caps.xml"), "rb").read(), desc_xml=open(resource_file("wps_fly_desc.xml"), "rb").read(), ) @@ -308,13 +301,17 @@ def test_xarray_converter(wps): # noqa: D103 @pytest.mark.online def test_geojson_geotiff_converters(wps): # noqa: D103 - pytest.importorskip("rasterio") + pytest.importorskip("rioxarray") + pytest.importorskip("xarray") + pytest.importorskip("geojson") + + import xarray as xr result = wps.geodata() raster, vector = result.get(asobj=True) assert isinstance(vector, dict) - assert hasattr(raster, "shape") + assert isinstance(raster, xr.Dataset) # Checking input validation shape = { diff --git a/tests/test_converters.py b/tests/test_converters.py index 4540ea3..fd4c229 100644 --- a/tests/test_converters.py +++ b/tests/test_converters.py @@ -8,6 +8,8 @@ from birdy.client import converters +from .common import resource_file + def test_all_subclasses(): # noqa: D103 c = converters.all_subclasses(converters.BaseConverter) @@ -94,3 +96,11 @@ def test_jpeg_imageconverter(): # noqa: D103 b = converters.convert(fn, path="/tmp") assert isinstance(b, bytes) + + +def test_raster_tif(): + pytest.importorskip("rioxarray") + fn = resource_file("Olympus.tif") + + ds = converters.convert(fn, path="/tmp") + assert "band_data" in ds.variables