Use of Python with GDAL. How to speed up ?

Serge Orlov Serge.Orlov at
Sat Mar 18 05:48:33 CET 2006

Julien Fiore wrote:
> Hi,
> I wrote a function to compute openness (a digital elevation model
> attribute). The function opens the gdal-compatible input raster and
> reads the values in a square window around each cell. The results are
> stored in a "1 line buffer". At the end of the line, the buffer is
> written to the output raster.
> It runs very slowly and I suspect the raster access to be the main
> bottleneck. Do you have any idea to speed-up the process ?

Psyco doesn't understand numpy AFAIK. So you have you have two options:
1) Rewrite the code to use array.array from stdlib instead of numpy,
then (hopefully) psyco will optimize it. Since array.array is
one-dimensional, it's not going to be fun.
2) Rewrite the code to be vectorized (don't use psyco) Right now your
code *doesn't* get any speed benefit from numpy

  -- Serge

More information about the Python-list mailing list