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.

COGReader.tile doesn't take into account mask band in some circumstances

See original GitHub issue

There is following set of files:

  • masked.tif (with PER_DATASET internal mask)
  • data.vrt built based on masked.tif
  • data.vrt.ovr (external overviews)

Let’s try to render a tile out of it:

In [1]: from rio_tiler.io import COGReader

In [2]: with COGReader("/tmp/test/data.vrt") as cog:
   ...:     tile = cog.tile(2323, 3503, 13, tilesize=256)
   ...: 
GDAL: GDALClose(/tmp/test/masked.tif, this=0x3699940)
GDAL: GDALClose(/tmp/test/data.vrt, this=0x3640b10)

In [3]: with open("/tmp/test/tile-ok.png", "wb") as dst:
   ...:     dst.write(tile.render())

Expected result (screenshot from QGIS):

image

Actual result:

tile-ok

Everything is fine.

Now let’s try to render tile on a lower zoom level, in this case GDAL will use existing overviews.

In [1]: from rio_tiler.io import COGReader

In [2]: with COGReader("/tmp/test/data.vrt") as cog:
   ...:     tile = cog.tile(72, 109, 8, tilesize=256)
   ...: 
GDAL: GDALClose(/tmp/test/masked.tif, this=0x2f1f7e0)
GDAL: GDALClose(/tmp/test/data.vrt, this=0x20b6740)
GDAL: GDALClose(/tmp/test/data.vrt.ovr, this=0x2e51cc0)

In [3]: with open("/tmp/test/tile-nok.png", "wb") as dst:
   ...:     dst.write(tile.render())
   ...: 

Expected result: image

Actual result: tile-nok

As you can see the mask has not been taken into account.

Files that are being used: example.zip

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
drnextgiscommented, Jul 2, 2021
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'
0reactions
drnextgiscommented, Jul 2, 2021

It did the trick!

Read more comments on GitHub >

github_iconTop Results From Across the Web

#and I'm back in my original office for the first time in over a year!! I'm ...
Teasing by rubbing the head around your clit before dragging it down to your awaiting hole. Fingers shoving into your cunt again, he...
Read more >
User friendly Rasterio plugin to read raster datasets.
rio-tiler was initialy designed to create slippy map tiles from ... COGReader.tile doesn't take into account mask band in some circumstances.
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