Database Reference
In-Depth Information
_n := (_value[3] - _value[1]);
_d := (_value[3] + (C1 * _value[1]) -
(C2 * _value[2]) + L
);
-- prevent division by zero
IF _d::numeric(16, 10) =
0.::numeric(16, 10) THEN
RETURN NULL;
END IF;
RETURN G * (_n / _d);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
Ifyoucan'tcreatethefunction,youprobablydonothavethenecessaryprivilegesin
the database.
Thereareseveralcharacteristicsrequiredforallofthecallbackfunctions.Theseare
as follows:
• All
ST_MapAlgebra()
callbackfunctionsmusthavethreeinputparameters,
namely,
double precision[]
,
integer[]
, and
variadic text[]
.
The
value
parameter is a 3D array where the first dimension denotes the
raster index, the second dimension the Y axis, and the third dimension the
X axis. The position parameter is an array of two dimensions with the first
dimension indicating the raster index and the second dimension consisting
of the X, Y coordinates of the center pixel. The last parameter,
userargs
,
isa1Darrayofzeroormoreelementscontainingvaluesthatauserwants
topasstothe
callback
function.Ifvisualized,theparameterslooklikethe
following:
value = ARRAY[
1 => [ -- raster 1
[pixval, pixval, pixval],
-- row of raster 1
[pixval, pixval, pixval],
[pixval, pixval, pixval]
],