[gdal-dev] question about ReadAsArray
Jorge Arévalo
jorge.arevalo at deimos-space.com
Tue Dec 14 13:21:01 EST 2010
Hi,
On Mon, Dec 13, 2010 at 11:33 PM, Matt Funk <mafunk at nmsu.edu> wrote:
> Hi,
>
> 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
http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/osgeo/gdal.py,
but the code which does the job is here
http://trac.osgeo.org/gdal/browser/trunk/gdal/swig/python/osgeo/gdal_array.py,
and rely on numpy
>
> thanks
> matt
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
Best regards,
--
Jorge Arévalo
Internet & Mobilty Division, DEIMOS
jorge.arevalo at deimos-space.com
http://mobility.grupodeimos.com/
http://gis4free.wordpress.com
More information about the gdal-dev
mailing list