<div dir="ltr">Thanks Joaquim and Even,<div><br></div><div><font face="arial, helvetica, sans-serif">Per my email I augmented the original GLOBE image and created a properly referenced image using gdal_translate as follows: I did an imread from QGIS/GDAL into Octave, added the appropriate 24 rows and columns on each side, and did an imwrite back to QGIS/GDAL to continue processing; however, I'm having a problem with negative elevations probably due to data type confusion.</font></div><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">1. GDAL reports the data type of the original GLOBE tiff file as int16. (file = output1.tiff)</font></div><div><font face="arial, helvetica, sans-serif">2. After using imread in Octave, Octave reports the data type as uint16.</font></div><div><font face="arial, helvetica, sans-serif">3. I retained the uint16 data type in Octave and added the additional rows and columns.</font></div><div><span style="font-family:arial,helvetica,sans-serif">4. I did an imwrite to create the augmented file. (file=output2.tiff)</span></div><div><span style="font-family:arial,helvetica,sans-serif">5. GDAL reports the data type of the augmented files as uint16.</span></div><div><span style="font-family:arial,helvetica,sans-serif">6. I performed the following GDAL command: gdal_translate </span><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">-a_ullr ulx uly lrx lry </span><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">src_dataset dst_dataset. (file=output3.tiff)</span><br></div><div><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">7. I then used gdalwarp to create the subsampled and cubic interpolated file (file=sample.tiff); GDAL report the data type as int16.</span></div><div><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)"><br></span></div><div><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">The problem is with locations with negative elevations that result in erroneous results when I subsequent subsample using gdal_warp. Here are the elevations reported by GDAL for one example pixel in the Caspian Sea:</span></div><div><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">output1.tiff (int16): -28 m</span></div><div><span style="font-family:arial,helvetica,sans-serif;background-color:rgb(251,252,253);color:rgb(0,0,0)">output2.tiff (uint16): 65508 m</span></div><div>output3.tiff (uint16): 65508 m</div><div><br></div><div>Unfortunately, Octave will not perform an imwrite with a int16 data type. Is it possible to fix this within QGIS/GDAL or is there another solution?</div><div><br></div><div>Thanks again for your help.</div><div><font face="arial, helvetica, sans-serif"><span style="background-color:rgb(251,252,253);color:rgb(0,0,0)"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="background-color:rgb(251,252,253);color:rgb(0,0,0)">Kind regards,</span></font></div><div><font face="arial, helvetica, sans-serif"><span style="background-color:rgb(251,252,253);color:rgb(0,0,0)"><br></span></font></div><div><font face="arial, helvetica, sans-serif"><span style="background-color:rgb(251,252,253);color:rgb(0,0,0)">Harvey</span></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Oct 9, 2017 at 9:32 AM, Joaquim Luis <span dir="ltr"><<a href="mailto:jluis@ualg.pt" target="_blank">jluis@ualg.pt</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><u></u>


<div style="font-family:'monospace';font-size:9pt;font-weight:400;font-style:normal"><div>Alternatively,  use GMT's grdsample with -fg option to force the knowledge (if it's not already in the file) that the Earth is round.</div><div><br></div><div><a href="http://gmt.soest.hawaii.edu/doc/5.4.2/grdsample.html" target="_blank">http://gmt.soest.hawaii.edu/<wbr>doc/5.4.2/grdsample.html</a></div><div><br></div><div><br></div><div><br></div><blockquote style="margin:0 0 0.80ex;border-left:#0000ff 2px solid;padding-left:1ex">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Harvey,</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> I subsampled a GLOBE image of elevation data by a subsampling factor of 12</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> to a resolution of 0.1 deg x 0.1 deg on integer multiples of 0.1 deg. The</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> original GLOBE image is: Latitude from +90-1/240 deg to -90+1/240 deg in</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> 1/120 deg steps, and Longitude from -180+1/240 deg to +180-1/240 deg in</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> 1/120 deg steps.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> I understand that the cubic interpolation method in gdalwarp accounts for</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> the subsampling factor, so 48x48 adjacent pixels influence the target pixel</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> for a subsampling factor of 12.</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Does gdalwarp assume the original image is a sphere, where 48x48 adjacent</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> pixels influence all target pixels, or a rectangle, where a limited number</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> of pixels influence the target pixels at the top, bottom, left, and right</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> edges of the subsampled image?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">A rectangle, with fallback to bilinear resampling at edges</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> If gdalwarp assumes the original image is a</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> rectangle and uses a modified interpolation method at the four edges of the</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> subsampled image, the modified method affects two rows and two columns at</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> the top, bottom, left and right edges of the subsampled image. If gdalwarp</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> assumes the original image is a rectangle, is there a command option so</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> gdalwarp considers spherical wrapping when interpolating? </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Nothing directly straightforward. Your below plan is the a reasonable solution.</p><span class="">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> Alternatively, I</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> assume I could augment the original GLOBE image with the appropriate</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> additional rows and columns on all four edges. If I did that, how do I tell</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">> gdalwarp the extent of the augmented input image?</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
</span><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">You'll have to recreate a properly referenced input image, for example with</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> gdal_translate -ullr upperleftx upperlefty lowerleftx lowerlefty</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Even</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"> </p><span class="HOEnZb"><font color="#888888">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">-- </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Spatialys - Geospatial professional services</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px"><a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a></p></font></span></blockquote><br><br><br></div><br>______________________________<wbr>_________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/gdal-dev" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/gdal-dev</a><br></blockquote></div><br></div>