<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>Chris,</p>
<p>ReadAsArray() returns a NumPy array, and the first dimension in
NumPy is the slowest varying one, that is y.</p>
<p>GDAL's geotransform is</p>
<p>Xgeoref = gt[0] + column * gt[1] + line * gt[2]</p>
<p>Ygeoref = gt[3] + column * gt[4] + line * gt[5]</p>
<p>and GDAL's Raster API have their arguments with column first,
line second.<br>
</p>
<p>So, there's no transposition. It is just a different convention
on how to present dimensions.</p>
<p>Note: if you used GDAL's multidimensional API, it would be
similar to NumPy convention, with slowest varying dimension being
the first index value.</p>
<p>Even<br>
</p>
<div class="moz-cite-prefix">Le 04/12/2022 à 09:02, Chris Crook a
écrit :<br>
</div>
<blockquote type="cite"
cite="mid:SY4PR01MB655391003B4C164638E5E833EC199@SY4PR01MB6553.ausprd01.prod.outlook.com">
<div class="elementToProof"><span>Hi </span></div>
<div class="elementToProof"><span><br>
</span></div>
<div class="elementToProof">
I am using the Python GDAL API and looking at a simple TIFF
image with a test program:</div>
<div class="elementToProof">
<br>
</div>
<div class="elementToProof ContentPasted0">
<div class="ContentPasted0">from osgeo import gdal</div>
<div class="ContentPasted0">dataset = gdal.Open('test-gdal.tif')</div>
<div class="ContentPasted0">transform=dataset.GetGeoTransform()<br>
</div>
<div class="ContentPasted0">nx=dataset.RasterXSize</div>
<div class="ContentPasted0">ny=dataset.RasterYSize</div>
<div class="ContentPasted0">data=dataset.ReadAsArray()</div>
<div>print(f"Raster xsize, ysize ({nx},{ny})")<br>
</div>
<div class="ContentPasted0">print(f"ReadAsArray dimensions
{data.shape}")</div>
<div class="ContentPasted0">print(f"GeoTransform: {transform}")</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0">The output is:</div>
<div class="ContentPasted0"><br>
</div>
<div class="ContentPasted0 ContentPasted1">test_python_api.py
<div class="ContentPasted1">Raster xsize, ysize (3,4)</div>
<div class="ContentPasted1">ReadAsArray dimensions (4, 3)</div>
<div class="ContentPasted1">GeoTransform: (22.15, 0.7, 0.0,
-69.5, 0.0, 1.0)</div>
<br>
</div>
<div class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1">I am confused that
the array appears transposed from the raster x,y size. </div>
<div class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1">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 class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1">Can I assume that the
array is always transposed? Or if not how do I identify when
this is the case?</div>
<div class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1">Many thanks in
advance</div>
<div class="ContentPasted0 ContentPasted1"><br>
</div>
<div class="ContentPasted0 ContentPasted1">Chris Crook</div>
<div class="ContentPasted0 ContentPasted1">Land Information New
Zealand</div>
<div class="ContentPasted0"><br>
</div>
<br>
</div>
<div class="elementToProof">
<br>
</div>
<div class="elementToProof">
<br>
</div>
<div class="elementToProof">
<div>
<br>
</div>
</div>
<br>
<hr>
<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 class="moz-txt-link-abbreviated" href="mailto:info@linz.govt.nz">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>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
gdal-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:gdal-dev@lists.osgeo.org">gdal-dev@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/gdal-dev">https://lists.osgeo.org/mailman/listinfo/gdal-dev</a>
</pre>
</blockquote>
<pre class="moz-signature" cols="72">--
<a class="moz-txt-link-freetext" href="http://www.spatialys.com">http://www.spatialys.com</a>
My software is free, but my time generally not.</pre>
</body>
</html>