Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overviews Read Incorrectly when Per Dataset Masks Present #3269

Closed
notthatbreezy opened this issue Jul 13, 2020 · 1 comment · Fixed by #3271
Closed

Overviews Read Incorrectly when Per Dataset Masks Present #3269

notthatbreezy opened this issue Jul 13, 2020 · 1 comment · Fixed by #3271
Assignees
Labels

Comments

@notthatbreezy
Copy link

Describe the bug

When a COG has per dataset masks the masks can be read as overviews incorrectly.

To Reproduce

Provide as able:

  • Use the COG in the attached zip file
  • Run the following code (create a rastersource, iterate over overviews to get band counts)
import geotrellis.raster.geotiff.GeoTiffRasterSource
val s = "<path to attached tiff>"
GeoTiffRasterSource(s).tiff.overviews.map(_.bandCount)

On my local machine this yielded the following:

scala> val s = "/mnt/c/Users/chris/projects/imagery/per-dataset-mask.tif"
s: String = /mnt/c/Users/chris/projects/imagery/per-dataset-mask.tif

scala> val rasterSource = GeoTiffRasterSource(s)
rasterSource: geotrellis.raster.geotiff.GeoTiffRasterSource = GeoTiffRasterSource(/mnt/c/Users/chris/projects/imagery/per-dataset-mask.tif)

scala> rasterSource.tiff.overviews.map(_.bandCount)
res6: List[Int] = List(1, 3, 1)

Showing 3 overviews with 1, 3, and 1 bands respectively.

Meanwhile gdalinfo shows there is only a single overview:

root@764d7618786e:/tmp# gdalinfo per-dataset-mask.tif
Driver: GTiff/GeoTIFF
Files: per-dataset-mask.tif
Size is 1024, 1024
Coordinate System is:
<ommitted>
Band 1 Block=512x512 Type=Byte, ColorInterp=Red
  Overviews: 512x512
  Mask Flags: PER_DATASET
  Overviews of mask band: 512x512
Band 2 Block=512x512 Type=Byte, ColorInterp=Green
  Overviews: 512x512
  Mask Flags: PER_DATASET
  Overviews of mask band: 512x512
Band 3 Block=512x512 Type=Byte, ColorInterp=Blue
  Overviews: 512x512
  Mask Flags: PER_DATASET
  Overviews of mask band: 512x512

Expected behavior

Only overviews are returned, masks are not returned

Additional context

Based on the documentation in gdal I suspect the raster masks are getting read as overviews because they are also put in the IFD, but do not represent lower resolution images.

@notthatbreezy
Copy link
Author

per-dataset-mask.zip

Here is a tiff used to reproduce the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants