<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Aptos;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
{font-family:"var\(--ff-mono\)";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:12.0pt;
font-family:"Aptos",sans-serif;}
code
{mso-style-priority:99;
font-family:"Courier New";}
pre
{mso-style-priority:99;
mso-style-link:"HTML-esimuotoiltu Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTML-esimuotoiltuChar
{mso-style-name:"HTML-esimuotoiltu Char";
mso-style-priority:99;
mso-style-link:HTML-esimuotoiltu;
font-family:Consolas;}
span.Shkpostityyli22
{mso-style-type:personal-reply;
font-family:"Aptos",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
mso-ligatures:none;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 70.85pt 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="FI" link="#467886" vlink="#96607D" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US">Do you suppose that the result would be two files:<br>
"Ortho2024_3857_10cm_mask.tif"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US">"Ortho2024_3857_10cm_mask.tif.msk"<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US">What the result is now? One file "Ortho2024_3857_10cm_mask.tif" with an internal mast band, or what?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US">-Jukka Rahkonen-<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:11.0pt;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Lähettäjä:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> gdal-dev <gdal-dev-bounces@lists.osgeo.org>
<b>Puolesta </b>Maxime Demers via gdal-dev<br>
<b>Lähetetty:</b> maanantai 27. tammikuuta 2025 17.58<br>
<b>Vastaanottaja:</b> gdal-dev@lists.osgeo.org<br>
<b>Aihe:</b> [gdal-dev] using gdal.Warp to reproject a GTiff with an external nodata mask (.msk)<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="margin-bottom:13.2pt">
<p class="MsoNormal" style="margin-bottom:12.0pt"><span style="font-size:11.0pt;color:black">Hi everybody, I hope you are all well!<o:p></o:p></span></p>
</div>
<div style="margin-bottom:13.2pt">
<p class="MsoNormal"><span style="font-size:11.0pt;color:black">I have an issue that I would need help about if possible.<o:p></o:p></span></p>
</div>
<div style="margin-bottom:13.2pt">
<p class="MsoNormal"><span style="font-size:11.0pt;color:black">I would like to use the GDAL Python bindings to reproject a TIFF that has an external nodata mask stored in a separate
</span><code><span style="font-size:10.0pt;font-family:"var(--ff-mono)",serif;color:black">.msk</span></code><span style="font-size:11.0pt;color:black"> file. Also, this is important to me to keep the jpeg compression.<o:p></o:p></span></p>
</div>
<div style="margin-bottom:13.2pt">
<p class="MsoNormal"><span style="font-size:11.0pt;color:black">After some tests, I found out that
</span><code><span style="font-size:10.0pt;font-family:"var(--ff-mono)",serif;color:black">gdal.Warp</span></code><span style="font-size:11.0pt;color:black"> does not reproject the
</span><code><span style="font-size:10.0pt;font-family:"var(--ff-mono)",serif;color:black">.msk</span></code><span style="font-size:11.0pt;color:black"><o:p></o:p></span></p>
</div>
<div style="margin-bottom:13.2pt">
<p class="MsoNormal"><span style="font-size:11.0pt;color:black">Is there a way to acheive what I am trying to do?<o:p></o:p></span></p>
</div>
<pre style="border-radius: var(--br-md);max-height: 600px"><code><span style="color:black">import os<o:p></o:p></span></code></pre>
<pre><code><span style="color:black">from osgeo import gdal<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span style="color:black">IN_RASTER = os.path.join(r"C:\\", "data", "Ortho", "Ortho2024_32187_10cm_mask.tif")<o:p></o:p></span></code></pre>
<pre><code><span style="color:black">OUT_RASTER = os.path.join(r"C:\\", "data", "Ortho", "Ortho2024_3857_10cm_mask.tif")<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span style="color:black">src = gdal.Open(IN_RASTER)<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span style="color:black">dst = gdal.Warp(<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> OUT_RASTER,<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> src,<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> format="GTiff",<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> dstSRS="EPSG:3857",<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> creationOptions=["COMPRESS=JPEG", "PHOTOMETRIC=YCBCR", "TILED=YES", "BIGTIFF=YES"],<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"> callback=gdal.TermProgress_nocb<o:p></o:p></span></code></pre>
<pre><code><span style="color:black">)<o:p></o:p></span></code></pre>
<pre><code><span style="color:black"><o:p> </o:p></span></code></pre>
<pre><code><span style="color:black">dst = None</span></code><span style="font-size:11.0pt;font-family:"Aptos",sans-serif;color:black"><o:p></o:p></span></pre>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:11.0pt;color:black"><o:p> </o:p></span></p>
</div>
<div id="Signature">
<table class="MsoNormalTable" border="0" cellspacing="0" cellpadding="0" width="764" style="width:572.7pt;margin-left:1.0pt;border-collapse:collapse">
<tbody>
<tr style="height:54.25pt">
<td width="225" valign="top" style="width:168.7pt;padding:0cm 5.4pt 0cm 0cm;height:54.25pt">
<p><span style="font-family:"Arial",sans-serif;color:#002060"><img width="216" height="112" style="width:2.25in;height:1.1666in" id="Kuva_x0020_1" src="cid:image001.png@01DB70E5.9C908420"></span><o:p></o:p></p>
</td>
<td width="539" valign="top" style="width:404.0pt;padding:0cm 5.4pt 0cm 0cm;height:54.25pt">
<p><b><span style="font-family:"Arial",sans-serif;color:#002060"> </span></b><o:p></o:p></p>
<p><b><span style="font-family:"Arial",sans-serif;color:#002C51">Maxime Demers</span></b><o:p></o:p></p>
<p><span style="font-family:"Arial",sans-serif;color:#002C51">Analyste en géomatique</span><o:p></o:p></p>
<p><span style="font-family:"Arial",sans-serif;color:#002C51">Service de la planification</span><o:p></o:p></p>
<p><span style="font-family:"Arial",sans-serif;color:#002C51">et de la gestion du territoire</span><o:p></o:p></p>
<p><span style="font-family:"Arial",sans-serif;color:#002C51">Tél. : 819 823-8000 poste 2360</span><o:p></o:p></p>
</td>
</tr>
</tbody>
</table>
<p> <o:p></o:p></p>
<p> <o:p></o:p></p>
</div>
</div>
</body>
</html>