png tiles for GEOTIFF files with band containing values in Float64?
rahulanand09 opened this issue · 4 comments
We are facing a problem while trying to fetch tiles for the Sentinel-1 TIFF file
downloaded with Google Earth Engine (GEE) using rio-tiler.
These Sentinel-1 files contain pixel data between range [+20, -20], and while using rio-tiler, we are an error that the GDAL’s png driver cannot work on Float64 TIFF files.
Is there a way that I can get png tiles for GEO TIFF files for band containing values in Float64?
Traceback (most recent call last):
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/functions_framework/__init__.py", line 87, in view_func
return function(request._get_current_object())
File "/workspace/main.py", line 61, in hello_world
return (getTilePNG(tilesQueryObject), 200, headers)
File "/workspace/main.py", line 20, in getTilePNG
return Response(image.render( img_format="PNG"), mimetype='image/png')
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/rio_tiler/models.py", line 262, in render
return render(self.data, self.mask, img_format=img_format, **kwargs)
File "/layers/google.python.pip/pip/lib/python3.8/site-packages/rio_tiler/utils.py", line 381, in render
dst.write(mask.astype(data.dtype), indexes=count + 1)
File "rasterio/_base.pyx", line 394, in rasterio._base.DatasetBase.__exit__
File "rasterio/_base.pyx", line 385, in rasterio._base.DatasetBase.close
File "rasterio/_io.pyx", line 2111, in rasterio._io.BufferedDatasetWriterBase.stop
File "rasterio/_err.pyx", line 215, in rasterio._err.exc_wrap_pointer
rasterio._err.CPLE_NotSupportedError: PNG driver doesn't support data type Float64. Only eight bit (Byte) and sixteen bit (UInt16) bands supported.
@rahulanand09 This is not a rio-cogeo bug!
PNG driver doesn't support data type Float64. Only eight bit (Byte) and sixteen bit (UInt16) bands supported.
Is there a way that I can get png tiles for GEO TIFF files for band containing values in Float64?
Sentinel 1 are in Float64, PNG support only Byte data. You'll have to rescale the data from float64 to byte before being able to create a PNG.
@vincentsarago - We are using GDAL scale to scale the data to byte. Is there a better way to it without losing much information.
I am trying to render other spectral indices on the browser as well. What would be the best way to achieve the same?
@rahulanand09 I'm not sure to understand,
can you share the data you are using?
I am trying to render other spectral indices on the browser as well. What would be the best way to achieve the same?
This is pretty vague. please checkout https://developmentseed.org/titiler/dynamic_tiling/ and feel free to start discussion over TiTiler discussion
I agree with @vincentsarago , this doesn't look like a bug. If you think otherwise, could you create a minimal reproducible example?