Returns new band with values reclassified.
298 uint32_t src_hasnodata = 0;
301 assert(NULL != srcband);
306 rterror(
"%s: reclassification map must contain at least one class pair", __func__);
310 if (!(src_hasnodata || hasnodata))
311 rterror(
"%s: source band missing nodata value and nodata value not supplied", __func__);
317 if (!hasnodata && src_hasnodata) {
319 hasnodata = src_hasnodata;
325 numval = width * height;
328 mem = (
int *)
rtalloc(memsize);
330 rterror(
"%s: Could not allocate memory for band", __func__);
334 rterror(
"%s: Could not add band to raster. Aborting", __func__);
352 for (uint32_t
x = 0;
x < width;
x++) {
353 for (uint32_t
y = 0;
y < height;
y++) {
355 double nv = nodataval;
381 rterror(
"%s: Could not assign value to new band", __func__);
void rt_band_init_value(rt_band band, double initval)
Fill in the cells of a band with a starting value frequently used to init with nodata value.
rt_band rt_band_new_inline(uint16_t width, uint16_t height, rt_pixtype pixtype, uint32_t hasnodata, double nodataval, uint8_t *data)
Create an in-db rt_band with no data.
void rt_band_set_ownsdata_flag(rt_band band, int flag)
void rterror(const char *fmt,...) __attribute__((format(printf
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
void rt_band_destroy(rt_band band)
Destroy a raster band.
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
void rtdealloc(void *mem)
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
static int rt_classpair_cmp(const void *aptr, const void *bptr)
static double rt_band_reclass_round_integer(rt_pixtype pixtype, double nv)
struct rt_classpair_t * pairs