79 int32_t bandindex = 0;
83 bool exclude_nodata_value =
TRUE;
87 bandindex = PG_GETARG_INT32(1);
88 if ( bandindex < 1 ) {
89 elog(NOTICE,
"Invalid band index (must use 1-based). Returning NULL");
93 x = PG_GETARG_INT32(2);
95 y = PG_GETARG_INT32(3);
97 exclude_nodata_value = PG_GETARG_BOOL(4);
102 if (PG_ARGISNULL(0)) PG_RETURN_NULL();
103 pgraster = (
rt_pgraster *)PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
107 PG_FREE_IF_COPY(pgraster, 0);
108 elog(ERROR,
"RASTER_getPixelValue: Could not deserialize raster");
115 elog(NOTICE,
"Could not find raster band of index %d when getting pixel " 116 "value. Returning NULL", bandindex);
118 PG_FREE_IF_COPY(pgraster, 0);
126 if (result !=
ES_NONE || (exclude_nodata_value && isnodata)) {
128 PG_FREE_IF_COPY(pgraster, 0);
133 PG_FREE_IF_COPY(pgraster, 0);
135 PG_RETURN_FLOAT8(pixvalue);
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
#define POSTGIS_RT_DEBUGF(level, msg,...)
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.