[gdal-dev] question about ReadAsArray
Ricardo Filipe Soares Garcia da
ricardo.garcia.silva at gmail.com
Tue Dec 14 16:32:12 EST 2010
well, the ReadAsArray function will return a numpy array of dimension 2.
In numpy the array.size() function will return (number_of_lines,
The number of lines in the array is the same as the YSize of the
raster in GDAL, and the number of columns is the same as the XSize of
the raster, so it means you are getting the expected result.
2010/12/14 Jorge Arévalo <jorge.arevalo at deimos-space.com>:
> On Mon, Dec 13, 2010 at 11:33 PM, Matt Funk <mafunk at nmsu.edu> wrote:
>> i am a bit new to the gdal library. I am trying to process some geotiff
>> files in python.
>> 1) I am making a call to the ReadAsArray data as such:
>> band = ds.GetRasterBand(1)
>> array = band.ReadAsArray(0,0,band.XSize,band.YSize)
>> print array.shape
>> which returns: (7191, 8331)
>> Now, what i don't understand is that when i do:
>> print 'Size is ',ds.RasterXSize,'x',ds.RasterYSize, 'x',ds.RasterCount
>> i get: Size is 8331 x 7191 x 1
>> So does that mean that ReadAsArray returns the an array that has its
>> dimensions flipped?
> If I'm not wrong (I'm looking at the code), yes, the Y coord is put
> before the X coord.
>> 2) Where can i find the documentation for the ReadAsArray fcn?
> You can find the function here
> but the code which does the job is here
> and rely on numpy
>> gdal-dev mailing list
>> gdal-dev at lists.osgeo.org
> Best regards,
> Jorge Arévalo
> Internet & Mobilty Division, DEIMOS
> jorge.arevalo at deimos-space.com
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
___________________________ ___ __
Ricardo Garcia Silva
More information about the gdal-dev