[gdal-dev] using gdal.Warp to reproject a GTiff with an external nodata mask (.msk)
Even Rouault
even.rouault at spatialys.com
Mon Jan 27 08:08:08 PST 2025
Le 27/01/2025 à 17:04, Even Rouault via gdal-dev a écrit :
>
> Maxime,
>
>
> you need to do in 2 steps, with something like (didn't test, slight
> modifications may be needed):
>
> - slightly modify your first step, to reproject to an intermediate
> RGBA dataset, with dstAlpha=yes. That temporary dataset may be a VRT,
> or a GeoTIFF with a lossless compression (ie DEFLATE)
>
> - convert from RGBA to RGB+mask with gdal.Translate(out,
> tmp_dataset_of_previous_step, bandList=[1,2,3], maskBand=4,
> creationOptions=["COMPRESS=JPEG", "PHOTOMETRIC=YCBCR", "TILED=YES",
> "BIGTIFF=YES"])
>
>
if you want an external mask to be generated you also need to run the
gdal.Translate() step under
with gdal.config_option("GDAL_TIFF_INTERNAL_MASK", "NO"):
> Even
>
>
> Le 27/01/2025 à 16:58, Maxime Demers via gdal-dev a écrit :
>> 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|
>>
>>
>>
>>
>>
>> **
>>
>> *Maxime Demers*
>>
>> Analyste en géomatique
>>
>> Service de la planification
>>
>> et de la gestion du territoire
>>
>> Tél. : 819 823-8000 poste 2360
>>
>>
>> _______________________________________________
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> --
> http://www.spatialys.com
> My software is free, but my time generally not.
> "De l'égo à l'égoût, il n'y a qu'une bouche mal refermée", André Isaac
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
"De l'égo à l'égoût, il n'y a qu'une bouche mal refermée", André Isaac
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250127/bf9c3a2a/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Outlook-jpt0bp2p.png
Type: image/png
Size: 11331 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20250127/bf9c3a2a/attachment-0001.png>
More information about the gdal-dev
mailing list