Get a raster as a surface (multipolygon).
If a band is specified, those pixels with value (not NODATA) contribute to the area of the output multipolygon.
362 GEOSGeometry *gc = NULL;
363 GEOSGeometry *gunion = NULL;
364 GEOSGeometry **geoms = NULL;
368 assert(surface != NULL);
386 rterror(
"rt_raster_surface: Could not get convex hull of raster");
399 rterror(
"rt_raster_surface: The band index %d is invalid",
nband);
406 rterror(
"rt_raster_surface: Error getting band %d from raster",
nband);
419 rterror(
"rt_raster_surface: Could not get convex hull of raster");
443 RASTER_DEBUG(3,
"All pixels of band are NODATA. Returning NULL");
448 else if (gvcount > 1) {
450 geomscount = gvcount;
451 geoms =
rtalloc(
sizeof(GEOSGeometry *) * geomscount);
453 rterror(
"rt_raster_surface: Could not allocate memory for pixel polygons as GEOSGeometry");
454 for (i = 0; i < gvcount; i++)
lwpoly_free(gv[i].geom);
458 for (i = 0; i < gvcount; i++) {
459 #if POSTGIS_DEBUG_LEVEL > 3 473 gc = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, geoms, geomscount);
476 rterror(
"rt_raster_surface: Could not create GEOS GEOMETRYCOLLECTION from set of pixel polygons");
478 for (i = 0; i < geomscount; i++)
479 GEOSGeom_destroy(geoms[i]);
485 gunion = GEOSUnaryUnion(gc);
487 GEOSGeom_destroy(gc);
490 if (gunion == NULL) {
491 rterror(
"rt_raster_surface: Could not union the pixel polygons using GEOSUnaryUnion()");
503 LWGEOM *mpolyValid = NULL;
505 if (GEOSisValid(gunion))
510 if (mpolyValid == NULL) {
511 rtwarn(
"Cannot fix invalid geometry");
520 GEOSGeom_destroy(gunion);
526 #if POSTGIS_DEBUG_LEVEL > 3 543 #if POSTGIS_DEBUG_LEVEL > 3 567 #if POSTGIS_DEBUG_LEVEL > 3 576 #if POSTGIS_DEBUG_LEVEL > 3
int rt_raster_get_num_bands(rt_raster raster)
int lwgeom_is_collection(const LWGEOM *lwgeom)
Determine whether a LWGEOM can contain sub-geometries or not.
char * lwgeom_to_wkt(const LWGEOM *geom, uint8_t variant, int precision, size_t *size_out)
WKT emitter function.
void lwgeom_free(LWGEOM *geom)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
LWGEOM * lwgeom_clone_deep(const LWGEOM *lwgeom)
Deep clone an LWGEOM, everything is copied.
LWGEOM * lwgeom_as_multi(const LWGEOM *lwgeom)
Create a new LWGEOM of the appropriate MULTI* type.
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
LWMPOLY * lwgeom_as_lwmpoly(const LWGEOM *lwgeom)
rt_errorstate rt_raster_get_convex_hull(rt_raster raster, LWGEOM **hull)
Get raster's convex hull.
LWGEOM * lwgeom_make_valid(LWGEOM *geom)
Attempts to make an invalid geometries valid w/out losing points.
void lwgeom_geos_error(const char *fmt,...)
void rtwarn(const char *fmt,...)
void lwpoly_free(LWPOLY *poly)
rt_geomval rt_raster_gdal_polygonize(rt_raster raster, int nband, int exclude_nodata_value, int *pnElements)
Returns a set of "geomval" value, one for each group of pixel sharing the same value for the provided...
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
void rtinfo(const char *fmt,...)
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
#define RASTER_DEBUGF(level, msg,...)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
GEOSGeometry * LWGEOM2GEOS(const LWGEOM *lwgeom, int autofix)
void rtdealloc(void *mem)
#define RASTER_DEBUG(level, msg)
LWGEOM * GEOS2LWGEOM(const GEOSGeometry *geom, char want3d)
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
void lwgeom_set_srid(LWGEOM *geom, int srid)
Set the SRID on an LWGEOM For collections, only the parent gets an SRID, all the children get SRID_UN...