Chris,
ReadAsArray() returns a NumPy array, and the first dimension in NumPy is
the slowest varying one, that is y.
GDAL's geotransform is
Xgeoref = gt[0] + column * gt[1] + line * gt[2]
Ygeoref = gt[3] + column * gt[4] + line * gt[5]
and GDAL's Raster API have their arguments with column first, line second.
So, there's no transposition. It is just a different convention on how
to present dimensions.
Note: if you used GDAL's multidimensional API, it would be similar to
NumPy convention, with slowest varying dimension being the first index
value.
Even
Le 04/12/2022 à 09:02, Chris Crook a écrit :
Hi
I am using the Python GDAL API and looking at a simple TIFF image with
a test program:
from osgeo import gdal
dataset = gdal.Open('test-gdal.tif')
transform=dataset.GetGeoTransform()
nx=dataset.RasterXSize
ny=dataset.RasterYSize
data=dataset.ReadAsArray()
print(f"Raster xsize, ysize ({nx},{ny})")
print(f"ReadAsArray dimensions {data.shape}")
print(f"GeoTransform: {transform}")
The output is:
test_python_api.py
Raster xsize, ysize (3,4)
ReadAsArray dimensions (4, 3)
GeoTransform: (22.15, 0.7, 0.0, -69.5, 0.0, 1.0)
I am confused that the array appears transposed from the raster x,y size.
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.
Can I assume that the array is always transposed? Or if not how do I
identify when this is the case?
Many thanks in advance
Chris Crook
Land Information New Zealand
------------------------------------------------------------------------
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 [email protected]) 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.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev
--
http://www.spatialys.com
My software is free, but my time generally not.
_______________________________________________
gdal-dev mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/gdal-dev