<div dir="ltr"><div>Hi Chris</div><div><br></div><div>I am not an expert in python. But I had similar problems in other environments.<br></div><div>At <a href="https://gdal.org/api/python/osgeo.gdal.html">https://gdal.org/api/python/osgeo.gdal.html</a> you can see that in many functions the numpy array returned is always in the form "array[y][x]". Looks like the shape in stored as "row,cols", not as "x,y". <br></div><div><br></div><div>Cheers<br></div><div><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">.___ ._ ..._ .. . ._.  .___ .. __ . _. . __..  ... .... ._ .__<br>Entre dos pensamientos racionales <br>hay infinitos pensamientos irracionales.<br><br></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 4 Dec 2022 at 09:02, Chris Crook <<a href="mailto:ccrook@linz.govt.nz">ccrook@linz.govt.nz</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"><div class="msg-3960222849617094820">




<div dir="ltr">
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">Hi </span></div>
<div><span style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)"><br>
</span></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
I am using the Python GDAL API and looking at a simple TIFF image with a test program:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<div>from osgeo import gdal</div>
<div>dataset = gdal.Open('test-gdal.tif')</div>
<div>transform=dataset.GetGeoTransform()<br>
</div>
<div>nx=dataset.RasterXSize</div>
<div>ny=dataset.RasterYSize</div>
<div>data=dataset.ReadAsArray()</div>
<div>print(f"Raster xsize, ysize ({nx},{ny})")<br>
</div>
<div>print(f"ReadAsArray dimensions {data.shape}")</div>
<div>print(f"GeoTransform: {transform}")</div>
<div><br>
</div>
<div>The output is:</div>
<div><br>
</div>
<div>test_python_api.py
<div>Raster xsize, ysize (3,4)</div>
<div>ReadAsArray dimensions (4, 3)</div>
<div>GeoTransform: (22.15, 0.7, 0.0, -69.5, 0.0, 1.0)</div>
<br>
</div>
<div><br>
</div>
<div>I am confused that the array appears transposed from the raster x,y size.  </div>
<div><br>
</div>
<div>Is this always the cased.  As far as I can tell the geotransform is assuming x,y (0-2,0-3 values) to map indices to location, which is what I want to do.</div>
<div><br>
</div>
<div>Can I assume that the array is always transposed?  Or if not how do I identify when this is the case?</div>
<div><br>
</div>
<div>Many thanks in advance</div>
<div><br>
</div>
<div>Chris Crook</div>
<div>Land Information New Zealand</div>
<div><br>
</div>
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255)">
<br>
</div>
<div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
</div>
<br>
<hr>
<font size="2" face="Verdana" color="Black"><br>
This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please
 notify us immediately (Phone 0800 665 463 or <a href="mailto:info@linz.govt.nz" target="_blank">info@linz.govt.nz</a>) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.<br>
</font>
</div>

_______________________________________________<br>
gdal-dev mailing list<br>
<a href="mailto:gdal-dev@lists.osgeo.org" target="_blank">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/mailman/listinfo/gdal-dev</a><br>
</div></blockquote></div>