Open drnextgis opened 3 years ago
Make tile with gdal_translate (with mask):
$ gdal_translate -projwin 119974.152936 2855615.99731 265006.012536 2717757.29023 \
-outsize 256 256 data.vrt tile-gdal-mask.tif
Make tile with gdal_translate (without mask):
$ gdal_translate -mask none -projwin 119974.152936 2855615.99731 265006.012536 2717757.29023 \
-outsize 256 256 data.vrt tile-gdal-nomask.tif
@drnextgis thanks for the issue. can you tell which version of rasterio and GDAL you are using (and also which OS).
I'll investigate, but I've seen this kind of behaviour with some rasterio/gdal combination.
Note: rio-tiler doesn't do much, it might go down to rasterio/gdal
Here is my first look: https://gist.github.com/vincentsarago/945fd7bbd34c0603b2d6a55f9dc8d030
I don't see anything wrong 🤷♂️
@drnextgis could you produce a bigger file?
In [1]: import rasterio, rio_tiler, platform
In [2]: rasterio.__version__
Out[2]: '1.2.6'
In [3]: rio_tiler.__version__
Out[3]: '2.0.8'
In [4]: rasterio.gdal_version()
Out[4]: '3.3.0'
In [5]: platform.system()
Out[5]: 'Linux'
Thank you @vincentsarago for your prompt reply. Maybe I'm missing something but shouldn't these masks be the same?
https://gist.github.com/drnextgis/5a25cf2e87b380e034a72c4a150358c6
Yep you are right!
This should give the same result.
Oh I see now
your data has nodata set to 0
and a internal mask. This creates a conflict in rio-tiler here https://github.com/cogeotiff/rio-tiler/blob/master/rio_tiler/reader.py#L61-L67
Ah, good catch! In this case can we follow the same order of precedence as it is done in rasterio?
@drnextgis I think it's a bit more complexe because we are creating a WarpedVRT 🤷♂️
I think the least we could do is print a warning when nodata and mask or alpha is present!
In WarpedVRT, I don't think you can have a Mask and Nodata
There is one thing I fail to understand. If I delete NoData value from the original tif and read it using COGReader I get the correct dataset mask:
But if I read it through WarpedVRT then I can't see it:
can you try with WarpedVRT(src, add_alpha=True)
?
w
It did the trick!
There is following set of files:
PER_DATASET
internal mask)Let's try to render a tile out of it:
Expected result (screenshot from QGIS):
Actual result:
Everything is fine.
Now let's try to render tile on a lower zoom level, in this case GDAL will use existing overviews.
Expected result:
Actual result:
As you can see the mask has not been taken into account.
Files that are being used: example.zip