Get raster perimeter.
The perimeter is a 4 vertices (5 to be closed) single ring polygon bearing the raster's rotation and using projection coordinates.
188 uint16_t *_nband = NULL;
191 uint16_t _trim[4] = {0};
192 uint16_t
trim[4] = {0};
194 double gt[6] = {0.0};
202 assert(perimeter != NULL);
219 if (
nband >= numband) {
220 rterror(
"rt_raster_get_boundary: Band %d not found for raster",
nband);
231 _nband =
rtalloc(
sizeof(uint16_t) * numband);
232 if (_nband == NULL) {
233 rterror(
"rt_raster_get_boundary: Could not allocate memory for band indices");
238 for (i = 0; i < numband; i++)
244 for (i = 0; i < numband; i++) {
247 rterror(
"rt_raster_get_boundary: Could not get band at index %d", _nband[i]);
257 rterror(
"rt_raster_get_boundary: Could not get band perimeter");
262 for (j = 0; j < 4; j++) {
263 if (!isset[j] ||
trim[j] < _trim[j]) {
285 rterror(
"rt_raster_get_perimeter: Could not allocate memory for polygon ring");
290 rterror(
"rt_raster_get_perimeter: Could not construct point array");
308 raster->width - _trim[1], _trim[0],
326 _trim[3],
raster->height - _trim[2],
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
POINTARRAY * ptarray_construct(char hasz, char hasm, uint32_t npoints)
Construct an empty pointarray, allocating storage and setting the npoints, but not filling in any inf...
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
#define SRID_UNKNOWN
Unknown SRID value.
void ptarray_set_point4d(POINTARRAY *pa, uint32_t n, const POINT4D *p4d)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
rt_errorstate rt_raster_cell_to_geopoint(rt_raster raster, double xr, double yr, double *xw, double *yw, double *gt)
Convert an xr, yr raster point to an xw, yw point on map.
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
#define RASTER_DEBUGF(level, msg,...)
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.
uint16_t rt_raster_get_num_bands(rt_raster raster)
void rtdealloc(void *mem)
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
raster
Be careful!! Zeros function's input parameter can be a (height x width) array, not (width x height): ...
static char * trim(const char *input)
static rt_errorstate _rti_raster_get_band_perimeter(rt_band band, uint16_t *trim)