mapbox / rio-rgbify

Encoded arbitrary bit depth rasters in pseudo base-256
MIT License
99 stars 36 forks source link

Fix reprojection issue making plugin unusable & roll out new release #36

Closed daniel-j-h closed 10 months ago

daniel-j-h commented 2 years ago

Hey folks :wave:

I gave this rio plugin a try to quickly encode a DEM raster into tiles the mapbox raster-dem source understands.

I then hit the following issue

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/rio_rgbify/scripts/cli.py", line 84, in rgbify
    tiler.run(workers)
  File "/usr/local/lib/python3.8/dist-packages/rio_rgbify/mbtiler.py", line 354, in run
    for tile, contents in self.pool.imap_unordered(self.run_function,
  File "/usr/local/lib/python3.8/dist-packages/riomucho/single_process_pool.py", line 15, in imap_unordered
    yield func(item)
  File "/usr/local/lib/python3.8/dist-packages/rio_rgbify/mbtiler.py", line 129, in _tile_worker
    reproject(
  File "/usr/local/lib/python3.8/dist-packages/rasterio/env.py", line 387, in wrapper
    return f(*args, **kwds)
  File "/usr/local/lib/python3.8/dist-packages/rasterio/env.py", line 612, in wrapper
    return f(*args, **kwds)
  File "/usr/local/lib/python3.8/dist-packages/rasterio/warp.py", line 368, in reproject
    _reproject(
  File "rasterio/_warp.pyx", line 474, in rasterio._warp._reproject
  File "rasterio/_warp.pyx", line 433, in rasterio._warp._reproject
  File "rasterio/_io.pyx", line 1778, in rasterio._io.InMemoryRaster.__init__
  File "rasterio/_base.pyx", line 1444, in rasterio._base._osr_from_crs
  File "/usr/local/lib/python3.8/dist-packages/rasterio/crs.py", line 496, in from_user_input
    return cls.from_string(value, morph_from_esri_dialect=morph_from_esri_dialect)
  File "/usr/local/lib/python3.8/dist-packages/rasterio/crs.py", line 400, in from_string
    return cls.from_proj4(string)
  File "/usr/local/lib/python3.8/dist-packages/rasterio/crs.py", line 421, in from_proj4
    obj._crs = _CRS.from_proj4(proj)
  File "rasterio/_crs.pyx", line 369, in rasterio._crs._CRS.from_proj4
rasterio.errors.CRSError: The PROJ4 dict could not be understood. PROJ: proj_create: cannot expand init='epsg:3857' +type=crs
Traceback (most recent call last):
  File "rasterio/_crs.pyx", line 367, in rasterio._crs._CRS.from_proj4
  File "rasterio/_err.pyx", line 193, in rasterio._err.exc_wrap_int
rasterio._err.CPLE_AppDefinedError: PROJ: proj_create: cannot expand init='epsg:3857' +type=crs

which seems to be related to https://github.com/rasterio/rasterio/issues/1648 and due to us using the wrong way of specifying the epsg.

I fixed this issue locally and wanted to upstream it, but turns out we already have this commit https://github.com/mapbox/rio-rgbify/commit/822aafc06ce2f7c2247b24cfafdddc43b68a846e from March 29th 2018. And there is https://github.com/mapbox/rio-rgbify/pull/32 upper casing EPSG. But we simply never rolled out a new release, meaning we're still affected by this issue

Could you folks merge #32 and tag & upload a new release, otherwise this project is pretty much unusable by now.

sehHeiden commented 2 years ago

I encountered the same error.

Could you please correct line 132 of mbtiler.py to: dst_crs="epsg:3857",

daniel-j-h commented 10 months ago

April 8th 2022 was the last release fixing this issue: https://pypi.org/project/rio-rgbify/#history