[gdal-dev] using gdal.Warp to reproject a GTiff with an external nodata mask (.msk)

Maxime Demers maxime.demers at sherbrooke.ca
Mon Jan 27 07:58:08 PST 2025


Hi everybody, I hope you are all well!

I have an issue that I would need help about if possible.
I would like to use the GDAL Python bindings to reproject a TIFF that has an external nodata mask stored in a separate .msk file. Also, this is important to me to keep the jpeg compression.
After some tests, I found out that gdal.Warp does not reproject the .msk
Is there  a way to acheive what I am trying to do?

import os
from osgeo import gdal

IN_RASTER = os.path.join(r"C:\\", "data", "Ortho", "Ortho2024_32187_10cm_mask.tif")
OUT_RASTER = os.path.join(r"C:\\", "data", "Ortho", "Ortho2024_3857_10cm_mask.tif")

src = gdal.Open(IN_RASTER)

dst = gdal.Warp(
    OUT_RASTER,
    src,
    format="GTiff",
    dstSRS="EPSG:3857",
    creationOptions=["COMPRESS=JPEG", "PHOTOMETRIC=YCBCR", "TILED=YES", "BIGTIFF=YES"],
    callback=gdal.TermProgress_nocb
)

dst = None




[cid:ee2bb6c6-c1e9-4d52-95f5-652a02f428c8]



Maxime Demers

Analyste en géomatique

Service de la planification

et de la gestion du territoire

Tél. : 819 823-8000 poste 2360




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250127/287f9ad0/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-jpt0bp2p.png
Type: image/png
Size: 11331 bytes
Desc: Outlook-jpt0bp2p.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250127/287f9ad0/attachment-0001.png>


More information about the gdal-dev mailing list