Friday, 7 December 2018

How to speed up raster/map algebra in PostGIS?


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?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...