Trouble viewing COG with a mask
See original GitHub issueViewing a COG, if I don’t use comp or just DEFLATE it works, however I would like to reduce the file size of the aerial image significantly and therefore use JPEG.
However, when I do this I get the following error message:
GeoTIFF.js:392 AssertionError: Assertion failed. See https://openlayers.org/en/v6.12.0/doc/errors/#17 for details.
My “Workflow”:
I converted my GeoTIFF with GDAL:
gdal_translate ./../rawData/ortho_lindenrain.tif ./cog/ortho_lindenrain_JPEG.tif -of COG -co COMPRESS=JPEG -co NUM_THREADS=ALL_CPUS
I am using GDAL 3.4.1
The validation was looking good:
python validate_cloud_optimized_geotiff.py ./cog/ortho_lindenrain_JPEG.tif
./cog/ortho_lindenrain_JPEG.tif is a valid cloud optimized GeoTIFF
The size of all IFD headers is 307812 bytes
But when I add the COG to the layers of my Map:
const cog = new TileLayer({
source: new GeoTIFF({
sources: [
{
url: 'https://masterarbeit-cog.s3.eu-central-1.amazonaws.com/cog/ortho_lindenrain_JPEG.tif'
},
],
})
})
....
layers: [
new TileLayer({source: new OSM()}),
cog
],,
I got the error:
GeoTIFF.js:392 AssertionError: Assertion failed. See https://openlayers.org/en/v6.12.0/doc/errors/#17 for details.
what is describing that: resolutions must be sorted in descending order, what it should be…
You can find the inputData here: https://masterarbeit-cog.s3.eu-central-1.amazonaws.com/inputData/ortho_lindenrain.tif The Working on is here: https://masterarbeit-cog.s3.eu-central-1.amazonaws.com/cog/ortho_lindenrain.tif The JPEG-Compressed is here: https://masterarbeit-cog.s3.eu-central-1.amazonaws.com/cog/ortho_lindenrain_JPEG.tif
Issue Analytics
- State:
- Created 2 years ago
- Comments:24 (8 by maintainers)
Top GitHub Comments
I’ve got a branch going that respects the mask and renders the https://eu2.contabostorage.com/05d6beb9e6b74f478ed68e4e8c715a4a:geotiles/S2_COG_JPEG.tiff GeoTIFF like this:
I’ll clean this up and submit a PR in the next couple days.
In my interpretation of @ahocevar’s question, the question is whether the bug is in geotiff.js, or in OpenLayers. Noteworthy is that @undefinedSolutions reported it there first, and was sent here.
As a quick test I made a heavily subsampled Copernicus Sentinel-2 image of the Netherlands with four bands (RGBA). GeoTiff.io is based on Leaflet (and geotiff.js), and if it works there, the bug is in OpenLayers. If it does not work there either, we need a cleaner example.
First test: a four band image, without compression, regular GeoTiff, WGS84.
It works on GeoTiff.io and in OpenLayers (in an adaptation of this example).
Second test: a COG, without compression, WGS84.
It works on GeoTiff.io and in OpenLayers.
Third test: a COG, with JPEG compression, WGS84.
It renders on GeoTiff.io, but not as it should. This could be due to missing normalisation, however, the alpha mask is not captured either. In OpenLayers in triggers the aforementioned assertion error #17. The silly part: this image is so small there are no overviews in the COG and therefore no resolutions to be in the wrong order. In QGIS the image renders without issue.
Preliminary conclusion: the issue is not limited to OpenLayers alone.
The GeoTiffs used: S2_COG.zip. (GDAL 3.4.1)