Skip to content
New issue

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

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

Already on GitHub? # to your account

External mask overviews aren't copied correctly when creating internally-masked GeoTIFFs #754

Closed
mojodna opened this issue Jul 13, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@mojodna
Copy link

mojodna commented Jul 13, 2018

(Follow-on from discussion in rasterio/rasterio#1373.)

Expected behavior and actual behavior.

As part of COG generation, I'm splitting up image data from its corresponding mask. The image data is converted to YCbCr and bicubic/lanczos-resampled overviews are generated. The mask also has nearest neighbor-resampled overviews produced (and has DEFLATE compression applied). To create the final output of the pipeline, the processed image + mask data (replete with overviews) are merged into a COG containing an internal mask.

Steps to reproduce the problem.

# COG produced using this pipeline; we're going to ignore any overviews present and
# regenerate them
curl -O https://mojodna-temp.s3.amazonaws.com/internal-mask.tif

# copy bands 1,2,3 to intermediate.tif, mask to intermediate.tif.msk
gdal_translate -b 1 -b 2 -b 3 -mask mask internal-mask.tif intermediate.tif

# add overviews (possibly resampling in a way that would be disruptive to a mask (i.e.
# introduce values that aren't 0 or 255), e.g. bicubic)
gdaladdo intermediate.tif 2 4 8 16 32

# add overviews to the mask
gdaladdo intermediate.tif.msk 2 4 8 16 32

# create an internally-masked result (this is where COG options would be applied)
gdal_translate \
  -co COPY_SRC_OVERVIEWS=YES \
  --config GDAL_TIFF_INTERNAL_MASK YES \
  intermediate.tif out.tif

out.tif contains all expected overviews, although each of its mask overviews is incorrect (all 255, extracted using tiffcp out.tif,7 mask-ovr1.tif for the first level).

The same overview level from intermediate.tif.msk (tiffcp intermediate.tif.msk,1 intermediate-mask-ovr1.tif for the first level) contains correct values.

Operating system

Ubuntu 16.04 64 bit (Docker)

GDAL version and provenance

GDAL 2.3.1, built according to https://github.com/mojodna/docker-gdal/blob/master/Dockerfile.

rouault added a commit that referenced this issue Jul 14, 2018
rouault added a commit that referenced this issue Jul 14, 2018
rouault added a commit that referenced this issue Jul 14, 2018
…ernal. Fixes -co COPY_SRC_OVERVIEWS=YES of such datasets (fixes #754)
@rouault rouault self-assigned this Jul 14, 2018
@rouault rouault added the bug label Jul 14, 2018
@rouault rouault added this to the 2.3.2 milestone Jul 14, 2018
@mojodna
Copy link
Author

mojodna commented Jul 16, 2018

Hurrah, thank you!!

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

No branches or pull requests

2 participants