Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove rasterio converter #240

Merged
merged 6 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -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)
==================

Expand Down
18 changes: 1 addition & 17 deletions birdy/client/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ packaging
python-dateutil>=2.8.1
requests>=2.0
wrapt
pyOpenSSL
2 changes: 1 addition & 1 deletion requirements_extra.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ ipython
ipywidgets
netCDF4
pymetalink
rasterio
xarray
rioxarray
17 changes: 7 additions & 10 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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(),
)
Expand Down Expand Up @@ -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 = {
Expand Down
10 changes: 10 additions & 0 deletions tests/test_converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Loading