[gdal-dev] ReadAsArray: putting data in an already existent array
Even Rouault
even.rouault at mines-paris.org
Sat Mar 23 12:41:01 PDT 2013
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