<div dir="ltr"><div><div><div><div>Basically it seems to be an issue with interpreting "center" directives when doing the gdal_translate. Consider:<br><br>ncols 2<br>nrows 2<br>xllcenter 0.0<br>yllcenter 0.0<br>cellsize 1.0<br>nodata_value -999<br>2 2<br>2 2<br><br></div>gdalinfo on this file, will give the expected GeoTransform:<br><br>In [2]: ds = gdal.Open("center.asc")<br><br>In [3]: ds.GetGeoTransform()<br>Out[3]: (-0.5, 1.0, 0.0, 1.5, 0.0, -1.0)<br><br></div><div>Seems OK to me.<br></div><div><br></div>If I then do a gdal_translate: gdal_translate center.asc center.tif, I get another interpretation:<br><br>In [4]: ds = gdal.Open("center.tif")<br><br>In [5]: ds.GetGeoTransform()<br>Out[5]: (0.0, 1.0, 0.0, 1.0, 0.0, -1.0)<br><br></div>And, if I do a roundtrip: gdal_translate -of AAIGRID center.tif center_back.asc, I get:<br>ncols 2<br>nrows 2<br>xllcorner 0.000000000000<br>yllcorner -1.000000000000<br>cellsize 1.000000000000<br>NODATA_value -999<br> 2 2<br> 2 2<br><br></div>Which is definitely not the same GeoTransform as my input center.asc, but shifted half a cellsize from what I would expect...<br><br>In [6]: ds = gdal.Open("center_back.asc")<br><br>In [7]: ds.GetGeoTransform()<br>Out[7]: (0.0, 1.0, 0.0, 1.0, 0.0, -1.0)<br><br><br><br>GDAL version: <br><div>GDAL 1.11.2, released 2015/02/10<br><br></div><div>Cheers,<br></div><div>Simon<br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 18, 2015 at 9:38 PM, Simon Lyngby Kokkendorff <span dir="ltr"><<a href="mailto:silyko@gmail.com" target="_blank">silyko@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div><div><div>Hi List,<br><br></div> I have a geoid in AAIGRID-format, with the following header:<br><br>ncols 1001
<br>nrows 731
<br>xllcenter 400000.0
<br>yllcenter 6045000.0
<br>cellsize 500.0
<br>NODATA_value 9999<br><br></div>GDAL will read this just fine, and report:<br><br>Driver: AAIGrid/Arc/Info ASCII Grid<br>Files: dkgeoid13b.utm32<br>Size is 1001, 731<br>Coordinate System is `'<br>Origin = (399750.000000000000000,6410250.000000000000000)<br>Pixel Size = (500.000000000000000,-500.000000000000000)<br>Metadata:<br> AREA_OR_POINT=Point<br>Corner Coordinates:<br>Upper Left ( 399750.000, 6410250.000) <br>Lower Left ( 399750.000, 6044750.000) <br>Upper Right ( 900250.000, 6410250.000) <br>Lower Right ( 900250.000, 6044750.000) <br>Center ( 650000.000, 6227500.000) <br>Band 1 Block=1001x1 Type=Float32, ColorInterp=Undefined<br> NoData Value=9999<br><br></div>As expected, the upper left corner is shifted half a pixel. It is my understanding, that GDAL (GetGeoTransform) always uses the xulcorner, yulcorner (pixel) interpretation. However, I was suprised to see that after a <br><br>gdal_translate dkgeoid13b.utm32 hello.tif, I get:<br><br>>gdalinfo hello.tif<br>Driver: GTiff/GeoTIFF<br>Files: hej.tif<br>Size is 1001, 731<br>Coordinate System is `'<br>Origin = (400000.000000000000000,6410000.000000000000000)<br>Pixel Size = (500.000000000000000,-500.000000000000000)<br>Image Structure Metadata:<br> INTERLEAVE=BAND<br>Corner Coordinates:<br>Upper Left ( 400000.000, 6410000.000) <br>Lower Left ( 400000.000, 6044500.000) <br>Upper Right ( 900500.000, 6410000.000) <br>Lower Right ( 900500.000, 6044500.000) <br>Center ( 650250.000, 6227250.000) <br>Band 1 Block=1001x2 Type=Float32, ColorInterp=Gray<br> NoData Value=99<br></div><br>The GeoTransform is not shifted half a pixel, and is not the same as the AAIGRID i ran gdal_translate on?? So, I would have to interpret now the GeoTransform as xulcenter and yulcenter. This came as a suprise, and led to some bugs in our processing software.<br><br></div>Is this to be expected??<br><br></div>Cheers,<br></div>Simon Kokkendorff<br><div><div><div> <br><div> <br></div></div></div></div></div>
</blockquote></div><br></div>