[gdal-dev] ReadAsArray: putting data in an already existent array

Jan Heckman jan.heckman at gmail.com
Sat Mar 23 12:30:52 PDT 2013


Hi Diego,
I haven't checked this out, but my guess is that you should make a
(python)list of the arrays if you need to keep them.  If you don't need to
keep them, you might try to del(ete) myarray before the next ReadAsArray
call.
Of course there is a lower level function which accepts an address as you
suggest, but the question is whether it should be exposed.
Because of the potential for errors, exposing it might not be the best.
You could expose it yourself, probably, but I very much suggest trying my
suggestion first.
Good luck,
Jan

On Fri, Mar 22, 2013 at 6:47 PM, Diego Gnesi Bartolani <
diego.gnesi at gmail.com> wrote:

> 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)
>
> Of course, my_arr must have the correct size for storing incoming data.
>
> Thanks,
>
> Diego
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20130323/ada13dc5/attachment.html>


More information about the gdal-dev mailing list