<div dir="ltr">Thanks Even,<div><br></div><div>I managed to make them aligned (illustration: <a href="https://i.imgur.com/1TwmVMN.png">https://i.imgur.com/1TwmVMN.png</a>) from your valuable suggestion with these 2 commands (-tr are used same for both gdapwarp and -tap option is the critical):</div><div><br></div><div>gdalwarp -tr 0.0007161230037719291 -0.0007161230037719291 T32UQD_20200421T102021_TCI_60m.jp2 full_warp.tif -t_srs EPSG:4326 -dstnodata 0 -tap<br> <br>gdalwarp -tr 0.0007161230037719291 -0.0007161230037719291 crop.tif small_warp.tif -t_srs EPSG:4326 -dstnodata 0 -tap<br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, 12 May 2020 at 18:12, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div style="font-family:monospace;font-size:9pt;font-weight:400;font-style:normal">
<p style="margin:0px;text-indent:0px">On mardi 12 mai 2020 16:19:43 CEST Pham Huu Bang wrote:</p>
<p style="margin:0px;text-indent:0px">> Hello,</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> I've a Sentinel 2 UTM32 scene (JPEG2000 format).</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> What I want to do is:</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> + Warp this scene from UTM32 to EPSG:4326 by gdalwarp</p>
<p style="margin:0px;text-indent:0px">> gdalwarp T32UQD_20200421T102021_TCI_60m.jp2 -t_srs EPSG:4326 full_warp.tif</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> + Clip a small subset of this file by gdal_translate</p>
<p style="margin:0px;text-indent:0px">> gdal_translate -projwin 798326.68347 5795956.80269 799609.577326</p>
<p style="margin:0px;text-indent:0px">> 5794397.95642 T32UQD_20200421T102021_TCI_60m.jp2 crop.tif</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> Then warp this small subset also from UTM32 to EPSG:4326 by gdalwarp:</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> gdalwarp crop.tif -t_srs EPSG:4326 small_warp.tif -dstnodata 0</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> However, when I overlay the small_warp.tif on the full_warp.tif by</p>
<p style="margin:0px;text-indent:0px">> QGIS 2.14.9, I see the small file is not aligned on the big one.</p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> Illustration: <a href="https://i.stack.imgur.com/U5Vql.png" target="_blank">https://i.stack.imgur.com/U5Vql.png</a></p>
<p style="margin:0px;text-indent:0px">> </p>
<p style="margin:0px;text-indent:0px">> What can be the reason for it?</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">When you don't specify any target extent or resolution, gdalwarp guesses them from the input raster georeferencing and target SRS. It doesn't try to align on any particular resolution</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">You may want to use the -tr and -tap switches to specify a target resolution, and constraint the extents to be aligned on it.</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Another reason for the misalignment is that you use the default nearest resampling. Using -r cubic could likely improve things</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">To get perfectly overlapping images, you may also need to specify -et 0</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">Even</p>
<p style="margin:0px;text-indent:0px"> </p>
<p style="margin:0px;text-indent:0px">-- </p>
<p style="margin:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></div></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><br></div><div><font size="4"><b>Bang Pham Huu </b></font></div><div><font size="4"><b>-------------------------------------------------------------------------------------</b></font></div><b><div><b>Master of Science - </b><b>Research Assistant at Field Monitoring Center - 4 F, E3 Building</b></div>Viet Nam - Ha Noi National University - University of Engineering and Technology</b><div><b>Email: <a href="mailto:a09550@gmail.com" target="_blank">a09550@gmail.com</a> - Tel: +84 164.6339.217</b></div><div><b><font size="1"><br></font></b></div><div><span style="font-family:museo-sans,sans-serif;line-height:26px"><i><font size="1">“Life is like riding a bicycle. To keep your balance, you must keep moving.”― Albert Einstein</font></i></span><b><br></b></div><div><b><br></b><div><br></div><div><font size="4"><b><br></b></font></div><div><font size="4"><b><br></b></font></div><div><font size="4"><b><br></b></font></div><br><br></div></div></div>