[gdal-dev] R: Re: ReadAsArray: putting data in an already existent array
Diego Gnesi
diego.gnesi at gmail.com
Sat Mar 23 14:45:00 PDT 2013
Thank you Even!
------Messaggio originale------
Da: Even Rouault
A: gdal-dev at lists.osgeo.org
Cc: Diego Gnesi
Oggetto: Re: [gdal-dev] ReadAsArray: putting data in an already existent array
Inviato: 23 mar 2013 20:41
Le vendredi 22 mars 2013 18:47:49, Diego Gnesi Bartolani a écrit :
> Hi,
>
> I'm programming in Python and I need to "scan" a large image with GDAL
> reading n rows at the time. I'm using the ReadAsArray method, but every
> time I execute it I get a new array. I think this solution consumes a lot
> of resources.
> Is there a method or option to pass to ReadAsArray an array that already
> exists, in order to change it's value, like in the following pseudo-code:
>
> band1 = ds.GetRasterBand(1)
> my_arr = band1.ReadAsArrray([params])
> [Do something with my_arr]
> band1.ReadAsArray([params to get other rows], save_to=my_arr)
You can try :
band1.ReadAsArray([params to get other rows], buf_obj = my_arr)
See
http://svn.osgeo.org/gdal/trunk/autotest/gcore/numpy_rw.py
>
> Of course, my_arr must have the correct size for storing incoming data.
>
> Thanks,
>
> Diego
More information about the gdal-dev
mailing list