[Gdal-dev] ReadAsArray()
Frank Warmerdam
warmerdam at pobox.com
Mon Mar 19 12:27:47 EDT 2007
Gong, Shawn (Contractor) wrote:
> Hi list,
>
> I have questions regarding ReadAsArray()
>
> Here is the code:
>
> msi_array = gdal_dataset.ReadAsArray().astype(Numeric.Float32)
>
> Q1: what is msi_array? Is it a Numeric array?
Shawn,
Yes
> Q2: printing out “print msi_array” generates a three-dimensional array
> (or list?)
>
> [ [ [0 1 2 up to col] ... ... up to row] ... up to bands]
>
> What function to call if I want to get a number of subarrays like:
>
> R = #1 band and 100x50 pixels
>
> G = #2 band and 100x50 pixels
>
> I have used
>
> r = msi_array[0:row][0:col][int(r_band)-1]
>
> g = msi_array[0:row][0:col][int(g_band)-1]
>
> b = msi_array[0:row][0:col][int(b_band)-1]
I believe you can just do:
r = msi_array[r_band-1]
g = msi_array[g_band-1]
b = msi_array[b_band-1]
Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush | President OSGeo, http://osgeo.org
More information about the Gdal-dev
mailing list