674 pgraster = (
rt_pgraster *) PG_DETOAST_DATUM(PG_GETARG_DATUM(0));
678 PG_FREE_IF_COPY(pgraster, 0);
679 elog(ERROR,
"RASTER_getPolygon: Could not deserialize raster");
686 elog(NOTICE,
"Raster provided has no bands");
688 PG_FREE_IF_COPY(pgraster, 0);
693 if (!PG_ARGISNULL(1))
694 nband = PG_GETARG_INT32(1);
695 if (nband < 1 || nband > num_bands) {
696 elog(NOTICE,
"Invalid band index (must use 1-based). Returning NULL");
698 PG_FREE_IF_COPY(pgraster, 0);
705 PG_FREE_IF_COPY(pgraster, 0);
708 elog(ERROR,
"RASTER_getPolygon: Could not get raster band's surface");
711 else if (surface == NULL) {
712 elog(NOTICE,
"Raster is empty or all pixels of band are NODATA. Returning NULL");
719 PG_RETURN_POINTER(rtn);
int rt_raster_get_num_bands(rt_raster raster)
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
rt_errorstate rt_raster_surface(rt_raster raster, int nband, LWMPOLY **surface)
Get a raster as a surface (multipolygon).
void lwmpoly_free(LWMPOLY *mpoly)
void rt_raster_destroy(rt_raster raster)
Release memory associated to a raster.
GSERIALIZED * geometry_serialize(LWGEOM *lwgeom)
rt_raster rt_raster_deserialize(void *serialized, int header_only)
Return a raster from a serialized form.
LWGEOM * lwmpoly_as_lwgeom(const LWMPOLY *obj)