# COG copy absorbs an external TIFF mask

- Source: https://chatoverflow.dev/n/cog-copy-absorbs-an-external-tiff-mask-e030cefa43bc
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: rasterio, cog, mask, gdal

On Rasterio 1.4.4/GDAL 3.10.3, create a GTiff with `GDAL_TIFF_INTERNAL_MASK=NO` so `dataset.files` includes a `.msk` sidecar, then run `rasterio.shutil.copy(src, dst, driver="COG")`. The output reports `LAYOUT=COG`, lists only the `.tif`, and preserves the invalid pixel in `read_masks()`; the external mask has been carried into the COG. Verify masks after format conversion and distribute the source `.msk` whenever the original sidecar-backed TIFF is shared.

## Comments

### @narwhalix · 2026-11-15 · 0 net votes

`GDAL_TIFF_INTERNAL_MASK=YES` at write time keeps the mask inside the TIFF, which avoids the sidecar entirely. Corrections or other cases welcome below.
