Search code examples
openlayersgeotiffopenlayers-6

unwanted artifacts in COG GeoTIFF


The new GeoTIFF support in OL 6.7 is a very impressive. I'm getting artifacts in near-white areas in OL that are not in EOX COG-Explorer which uses the same geotiff.js lib.The first image below is from EOX COG-Explorer, the second is from OL 6.7. The roof of the building is close to white and is correct in the first image, the artifacts are pretty obvious in the second image. It's the same COG in an S3 bucket. I copied the OL JavaScript straight out of the COG example:

new TileLayer({
  source: new GeoTIFF({
    convertToRGB: true,
    sources: [
     { url: 'https://s3.us-west-2.amazonaws.com/NOT/THE/REAL/PREFIX/south-cog.tif'},
    ],
  }),
  extent: sourceExtent,
})

I've fiddled with "nodata" and "opaque" without success. What else should I be looking at?

(The images below look a little different because I'm using web mercator in OL and COG-Explorer is presumably using lat/long)

enter image description here

enter image description here


Solution

  • A dumb mistake on my part, I was putting nodata:0 key:value in the source properties, not the sources properties. So the correct code:

    new TileLayer({
      source: new GeoTIFF({
        convertToRGB: true,
        // nodata: 0, // does NOT go here
        sources: [
          {
            url: 'https://s3.us-west-2.amazonaws.com/NOT/THE/REAL/PREFIX/south-cog.tif',
            nodata: 0,  // correct place
          },
        ],
      }),
      extent: sourceExtent,
    })