3

I am testing map algebra with PostGIS (2.1 with PostgreSQL 9.3) on two images, and found it to be rather slow. For example, dividing two images of 7200 * 3600 pixels took 110 ~ 120s on a desktop with i7 3.4 GHz CPU; the same operation with the same data took ArcGIS (10.1) 15 ~ 16s.

The SQL statement tested was based on this PostGIS example as follows:

SELECT ST_MapAlgebra(t1.rast,t2.rast
        ,'([rast1]+0.001)/([rast2]+0.001)') AS rast
FROM img1 t1, img2 t2 

The two rasters were imported using the following options:

 raster2pgsql -d -M -C -I -s 4326 ...

I did not use filesystem storage or tiling.

My question is:

What's the best way (if possible) to improve the above SQL for map algebra?

1

How about testing St_MapAlgebraExp

SELECT ST_MapAlgebraExp(t1.rast,t2.rast ,'([rast1]+0.001)/([rast2]+0.001)') AS rast FROM img1 t1, img2 t2

  • The page you linked to says "ST_MapAlgebraExpr is deprecated as of 2.1.0. Use ST_MapAlgebra instead." – bugmenot123 Aug 14 '15 at 13:06
  • It's really crasy, I'm using it and it's taking 10 s for a large raster – elmo Aug 14 '15 at 13:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.