Database Reference
In-Depth Information
As with
ST_MapAlgebra()
callback functions,
ST_MapAlgebraFct()
requires
callback functions to be structured in a specific manner. There is a difference
between the callback function for
ST_MapAlgebraFct()
and the prior one for
ST_MapAlgebra()
.Thisfunctionhastwosimplepixel-valueparametersinsteadof
an array for all pixel values.
SELECT
ST_MapAlgebraFct(
rast, 1, -- red band
rast, 4, -- NIR band
'modis_evi2(double precision,
double precision, int[],
text[])'::regprocedure, -- signature for
callback function
'32BF', -- output pixel type
'FIRST',
'1.', -- L
'2.4', -- C
'2.5' -- G
) AS rast
FROM modis m;
Besides the difference in function names,
ST_MapAlgebraFct()
is called dif-
ferently from
ST_MapAlgebra()
. The same raster is passed to
ST_MapAlgebraFct()
twice. The other difference is that there is one less user-
definedargumentbeingpassedtothe
callback
functionasthetwo-bandEVIhas
one less coefficient.
How it works...
We demonstrated some of the advanced uses of PostGIS's map-algebra functions
by computing the three-band and two-band EVIs from our MODIS raster. This was
achievedusing
ST_MapAlgebra()
and
ST_MapAlgebraFct()
respectively.With
some planning, PostGIS's map-algebra functions can be applied to other uses, for
example, edge detection and contrast stretching.