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

Fix reading raster compression value with rasterio 1.4.3 #300

Merged
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
2 changes: 1 addition & 1 deletion rio_cogeo/cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def cog_info(
with rasterio.Env(**config):
with rasterio.open(src_path) as src_dst:
driver = src_dst.driver
compression = src_dst.compression.value if src_dst.compression else None
compression = getattr(src_dst.compression, "value", src_dst.compression)
colorspace = src_dst.photometric.value if src_dst.photometric else None
overviews = src_dst.overviews(1)

Expand Down
12 changes: 8 additions & 4 deletions tests/test_cogeo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _validate_translated_rgb_jpeg(src):
assert all([(64, 64) == (h, w) for (h, w) in src.block_shapes])
assert src.profile["blockxsize"] == 64
assert src.profile["blockysize"] == 64
assert src.compression.value == "JPEG"
assert src.compression == "YCbCr JPEG" or src.compression.value == "JPEG"
assert src.photometric.value == "YCbCr"
assert src.interleaving.value == "PIXEL"
assert src.overviews(1) == [2, 4, 8]
Expand Down Expand Up @@ -101,7 +101,9 @@ def test_cog_translate_NodataLossyWarning(runner):
)
with rasterio.open("cogeo.tif") as src:
assert not src.nodata
assert src.compression.value == "JPEG"
assert (
src.compression == "YCbCr JPEG" or src.compression.value == "JPEG"
)
assert has_mask_band(src)


Expand Down Expand Up @@ -186,7 +188,9 @@ def test_cog_translate_validAlpha(runner):
)
with rasterio.open("cogeo.tif") as src:
assert src.count == 3
assert src.compression.value == "JPEG"
assert (
src.compression == "YCbCr JPEG" or src.compression.value == "JPEG"
)
assert has_mask_band(src)

with pytest.warns(UserWarning):
Expand Down Expand Up @@ -291,7 +295,7 @@ def test_cog_translate_validCustom(runner):
assert src.width == 512
assert src.meta["dtype"] == "uint8"
assert all([(256, 256) == (h, w) for (h, w) in src.block_shapes])
assert src.compression.value == "JPEG"
assert src.compression == "YCbCr JPEG" or src.compression.value == "JPEG"
assert src.profile["blockxsize"] == 256
assert src.profile["blockysize"] == 256
assert src.photometric.value == "YCbCr"
Expand Down
Loading