localtileserver: nodata causes padding
When nodata is set to a certain value (e.g., -1), there are some big black empty tiles surrounding the image.
from localtileserver import TileClient, get_leaflet_tile_layer, examples
from ipyleaflet import Map
client = TileClient('https://github.com/giswqs/data/raw/main/raster/landsat7.tif')
t = get_leaflet_tile_layer(client, nodata=-1)
m = Map(center=client.center(), zoom=client.default_zoom)
m.add(t)
m
nodata = -1
nodata=None
I noticed the example on the documentation page has a similar issue (a white background). However, it displays correctly when used locally.
https://localtileserver.banesullivan.com/
Local jupyter
About this issue
- Original URL
- State: closed
- Created 5 months ago
- Comments: 15 (7 by maintainers)
the data outside the raster is set to 0 instead of -1 (because of the datatype issue) so then when we are building the mask we don’t find the
-1valueSure it is, but the issue here is that the nodata value was set in the file while it should not have!
This is pretty hard, I don’t / can’t cover all data problem. The data provider should understand how raster works IMO. The overriding
nodatafeature was added because at the time of creation of rio-tiler, some organisation didn’t want to add the nodata metadata tag in their raster because it wasn’t part of the original TIFF specification.I’m pretty sure this is expected because you’re overriding the nodata value the
oceanwhich in theredandgreenbands should be close to DN=0 will then not me masked and thus result in weird colors. If you look at the data array you’ll understand.👋 after some time looking at the issue I’ve realized the problems are:
-1nodata value on auint16dataset, to GDAL will ignore it0value is proper dataSadly there is no option in rio-tiler to
ignorenodata value (just to overwrite) 😓The easiest way to fix this is to edit the file and to remove the
nodatavalueI tried light mode on my local Jupyter and Google Colab. This issue persists. Same thing for folium.