geotiff.js
geotiff.js copied to clipboard
Openlayers: COG with JPEG Compression has descending order
Viewing 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
@undefinedSolutions Sorry, I'm not quite understand the problem, it seems like some details were not transpired after this
But when I add it to the layers of my Map:
One wild guess is that with using JPEG compression, also the colorspace has changed (usually YCbCr, I think). So in order to correctly RGB-visualize it the colorspace needs to be converted. Fortunately this is all built into geotiff.js and you can enable it by using the convertToRGB: true
flag in the GeoTIFF source. See here for reference.
Sorry, I have now edited the text. I hope my problem is now clearer.
Adding convertToRGB: true is not working, the error stays the same
Ah, okay. This seems more related to the GeoTIFF integration in OpenLayers. Please open an issue there.
In my experience this error occurs when the GeoTIFF has an internal mask. It works fine with an alpha layer, but not an internal mask.