rasterio / rasterio-wheels

MIT License
11 stars 16 forks source link

LERC unsupported with 1.3.0 #94

Closed ajnisbet closed 1 year ago

ajnisbet commented 1 year ago

rasterio 1.2.10 supported reading from LERC-encoded rasters, but this no longer works since 1.3.0.

Here's a minimal Dockerfile that triggers the error:

FROM python:3.9.14-bullseye
COPY lerc.tif .
RUN pip install rasterio==1.3.2
RUN python -c "import rasterio; f = rasterio.open('lerc.tif'); print(f.read())"

fails with

Traceback (most recent call last):
  File "rasterio/_base.pyx", line 302, in rasterio._base.DatasetBase.__init__
  File "rasterio/_base.pyx", line 213, in rasterio._base.open_dataset
  File "rasterio/_err.pyx", line 217, in rasterio._err.exc_wrap_pointer
rasterio._err.CPLE_AppDefinedError: lerc.tif: Cannot open TIFF file due to missing codec.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.9/site-packages/rasterio/env.py", line 442, in wrapper
    return f(*args, **kwds)
  File "/usr/local/lib/python3.9/site-packages/rasterio/__init__.py", line 277, in open
    dataset = DatasetReader(path, driver=driver, sharing=sharing, **kwargs)
  File "rasterio/_base.pyx", line 304, in rasterio._base.DatasetBase.__init__
rasterio.errors.RasterioIOError: lerc.tif: Cannot open TIFF file due to missing codec.

versions 1.3.0 to 1.3.2 inclusive fail, 1.2.10 works fine.

The raster is encoded with

Image Structure Metadata:
  COMPRESSION=LERC
  INTERLEAVE=BAND
  LERC_VERSION=2.4

using GDAL 3.3.1 (installed with conda on ubuntu).

sgillies commented 1 year ago

@ajnisbet that I can recall, we've never intentionally supported LERC. See for example https://github.com/rasterio/rasterio-wheels/issues/70. Is it possible that you were previously installing rasterio from the conda-forge channel?

ajnisbet commented 1 year ago

The dockerfile pulls in the pypi wheel: LERC works with

rasterio-1.2.10-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl

and not with

rasterio-1.3.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

And even going back to 1.1.0 and python3.7 with rasterio-1.1.0-cp37-cp37m-manylinux1_x86_64.whl supports LERC

FROM python:3.7
COPY lerc.tif .
RUN pip install rasterio==1.1.0
RUN python -c "import rasterio; f = rasterio.open('lerc.tif'); print(f.read())"

It looks like the user from https://github.com/rasterio/rasterio-wheels/issues/70 is using conda-forge (https://github.com/rasterio/rasterio/issues/2270) not the wheels.


Anyway, if LERC isn't explicitly supported by the rasterio wheels that's fine, just wanted you to be aware of the potential regression!

It doesn't even actually effect me: I briefly used LERC a while ago before realising that zstd was about the same size and faster (and lossless!) and I had some leftover tests which started failing at 1.3.0. I just removed the tests, I've never seen LERC anywhere else in the wild.

sgillies commented 1 year ago

@ajnisbet thanks for the follow up! I suspect that a switch in this project from using GDAL's internal libtiff (which might have vendored LERC) to a system libtiff (shared with PROJ) is involved.

ajnisbet commented 1 year ago

Makes sense, I'll close the issue as it sounds like this is a (understandable) wontfix. Thanks for all your work on rasterio!

mmcfarland commented 1 year ago

We recently came across this behavior while attempting to upgrade rasterio and the titiler stack within the Microsoft Planetary Computer. We have about 380k LERC COGs and so are also interested in rasterio support (our setup previously worked, likely as described in this issue). Thanks for your work on this, and we'll keep an eye on #100.