[postgis-users] calculate NDVI from multiband raster

Pierre Racine Pierre.Racine at sbf.ulaval.ca
Wed Sep 14 05:21:13 PDT 2011


Hi Marco,

MapAlgebra taking multiple band or multiple raster is not implemented yet. You can however try the plpgsql prototype of two raster ST_Mapalgebra at:

http://trac.osgeo.org/postgis/browser/trunk/raster/scripts/plpgsql/st_mapalgebra.sql

Just execute the .sql file in PostgreSQL/PostGIS and do something like:

SELECT ST_MapAlgebra(ST_MapAlgebra(rast, 4, rast, 3, "rast1 - rast2", "32BSI"), ST_MapAlgebra(rast, 4, rast, 3, "rast1 + rast2", "32BSI"), "rast1 / rast2", "32BF")
FROM your rastertable

Be careful at the pixeltypes of the result of each ST_MapAlgebra call.

Let me know  how this works. Remember this is just a prototype (might be slow and buggy)...

Pierre

> how to access the specific bands to make st_mapalgebra calculate some new
> raster?
> 
> select st_mapalgebra(rast, '(4-3)/(4+3)') from foo; or select st_mapalgebra(rast,
> '(st_band(rast, 4)-st_band(rast, 3))/(st_band(rast, 4)+st_band(rast, 3))') from foo;
> 
> does not work
> 
> Marco
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users



More information about the postgis-users mailing list