[postgis-users] Why so terribly slow?
Pierre Racine
Pierre.Racine at sbf.ulaval.ca
Thu Feb 9 07:24:10 PST 2012
> I see, thanks for the tip. I used PL/PGSQL because some functions such as
> "ST_AsRaster" are implemented that way and are structurally similar to the ones
> I want to make. But well, after taking a look at the map algebra functions I think
> they will be helpful... I'll just have to go over the syntax of these kind of
> expressions. Thank you very much!
The syntax for ST_MapAlgebraExpr() is the same as a SQL expression with the addition of three keywords that you must put in your expression:
[rast.val] the value of the pixel being computed
[rast.x] the x raster coordinate of the pixel being computed
[rast.y] the y raster coordinate of the pixel being computed
There is the main expression and alternate expressions to deal with nodata values.
For two rasters ST_MapAlgebraExpr() the keywords are [rast1.val], [rast1.x], [rast1.y] and [rast2.val], [rast2.x], [rast2.y].
> pvaldes: the function I put up there is just a basic example with no utility. Later
> on, I'll want to work on fuzzy logic, weighted average...
For weighted average of raster values over the area covered by polygons see the tutorial (a bit outdated but the idea is the same):
http://trac.osgeo.org/postgis/wiki/WKTRasterTutorial01
there is now a st_areaweightedsummarystats() prototype function in:
http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql
to help computing the weighted average.
Pierre
More information about the postgis-users
mailing list