Database Reference
In-Depth Information
If the callback functions are not correctly structured, the
ST_MapAlgebra()
func-
tion will fail or behave incorrectly.
Inthefunctionbody,weconverttheuserargumentstotheircorrectdatatypes,res-
calethepixelvalues,checkthatnopixelvaluesare
NULL
(arithmeticoperationswith
NULL
valuesalwaysresultin
NULL
),computethenumeratoranddenominatorcom-
ponentsof
EVI
,checkthatthedenominatorisnotzero(topreventdivisionbyzero),
and then finish the computation of
EVI
.
Now we call our callback function
modis_evi()
with
ST_MapAlgebra()
.
SELECT
ST_MapAlgebra(
rast,
ARRAY[1, 3, 4]::int[], -- only
use the red, blue a
nd near infrared bands
'chap5.modis_evi(double
precision[], int[], t
ext[])'::regprocedure, -- signature for
callback function
'32BF', -- output pixel type
'FIRST',
NULL,
0, 0,
'1.', -- L
'6.', -- C1
'7.5', -- C2
'2.5' -- G
) AS rast
FROM modis m;
In our call to
ST_MapAlgebra()
, there are three criteria to take note of, as follows:
• The signature for the
modis_evi()
callback function. When passing the
callback function to
ST_MapAlgebra()
, it must be written as a string con-
taining the function name and the input-parameter types.