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.
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]) {
280 trim[0], trim[1], trim[2], trim[3]);
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],
317 raster->
width - _trim[1], raster->
height - _trim[2],
326 _trim[3], raster->
height - _trim[2],
void ptarray_set_point4d(POINTARRAY *pa, int n, const POINT4D *p4d)
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...
int rt_raster_get_num_bands(rt_raster raster)
void rt_raster_get_geotransform_matrix(rt_raster raster, double *gt)
Get 6-element array of raster geotransform matrix.
static rt_errorstate _rti_raster_get_band_perimeter(rt_band band, uint16_t *trim)
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
LWGEOM * lwpoly_as_lwgeom(const LWPOLY *obj)
int rt_raster_is_empty(rt_raster raster)
Return TRUE if the raster is empty.
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.
LWPOLY * lwpoly_construct(int srid, GBOX *bbox, uint32_t nrings, POINTARRAY **points)
#define SRID_UNKNOWN
Unknown SRID value.
rt_band rt_raster_get_band(rt_raster raster, int bandNum)
Return Nth band, or NULL if unavailable.
#define RASTER_DEBUGF(level, msg,...)
int32_t rt_raster_get_srid(rt_raster raster)
Get raster's SRID.
void rtdealloc(void *mem)
static char * trim(const char *input)
int rt_band_get_isnodata_flag(rt_band band)
Get isnodata flag value.