question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trouble viewing COG with a mask

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:24 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
tschaubcommented, Aug 26, 2022

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:

image

I’ll clean this up and submit a PR in the next couple days.

1reaction
fwritecommented, Jul 20, 2022

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.

gdalwarp -t_srs EPSG:4326 -tr 0.01 0.01 -r average -multi -of GTiff -co COMPRESS=NONE -co BIGTIFF=IF_NEEDED -wm 8000 /tmp/adriaan-ahn/SentinelNL/L2A_COG/20181013T105029_R051B_TCI.vrt /tmp/S2_RAW.tiff

It works on GeoTiff.io and in OpenLayers (in an adaptation of this example).

Second test: a COG, without compression, WGS84.

gdal_translate -of COG -co COMPRESS=NONE /tmp/S2_RAW.tiff /tmp/S2_COG.tiff

It works on GeoTiff.io and in OpenLayers.

Third test: a COG, with JPEG compression, WGS84.

gdal_translate -of COG -co COMPRESS=JPEG /tmp/S2_RAW.tiff /tmp/S2_COG_JPEG.tiff

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. image 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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

Struggling to wear a mask? Follow this advice | OSF HealthCare
If wearing a mask over your nose and mouth makes you feel like you can't breathe, there are two general explanations for that...
Read more >
Masks mess with our brain's ability to recognize faces, but ...
I have trouble enough recognizing faces of people I don't see often. Masks make it almost impossible if people have similar coloring and...
Read more >
Feeling Anxious About Wearing A Mask? Here Are 5 Ways To ...
Danger is afoot!” Our body will then respond by hyperventilating, becoming anxious, or panicking to alert us that there could be a problem,...
Read more >
Mask-Wearing Can Make It More Difficult to Recognize ...
When you are wearing a face mask, it may be more difficult for you to recognize people, even if they are not wearing...
Read more >
A Toolkit For Helping Your Child Wear A Mask During COVID-19
Once your child is comfortable wearing their mask for a little while, try to get them to wear it while they are doing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found