Returns new band with values reclassified.
62 double src_nodataval = 0.0;
76 assert(NULL != srcband);
77 assert(NULL != exprset && exprcount > 0);
89 numval = width * height;
93 rterror(
"rt_band_reclass: Could not allocate memory for band");
99 memset(mem, 0, memsize);
103 int32_t checkvalint = 0;
105 double checkvaldouble = 0;
106 float checkvalfloat = 0;
113 for (i = 0; i < numval; i++)
114 ptr[i] = clamped_initval;
115 checkvalint = ptr[0];
122 for (i = 0; i < numval; i++)
123 ptr[i] = clamped_initval;
124 checkvalint = ptr[0];
131 for (i = 0; i < numval; i++)
132 ptr[i] = clamped_initval;
133 checkvalint = ptr[0];
140 for (i = 0; i < numval; i++)
141 ptr[i] = clamped_initval;
142 checkvalint = ptr[0];
149 for (i = 0; i < numval; i++)
150 ptr[i] = clamped_initval;
151 checkvalint = ptr[0];
158 for (i = 0; i < numval; i++)
159 ptr[i] = clamped_initval;
160 checkvalint = ptr[0];
167 for (i = 0; i < numval; i++)
168 ptr[i] = clamped_initval;
169 checkvalint = ptr[0];
176 for (i = 0; i < numval; i++)
177 ptr[i] = clamped_initval;
178 checkvalint = ptr[0];
185 for (i = 0; i < numval; i++)
186 ptr[i] = clamped_initval;
187 checkvaluint = ptr[0];
194 for (i = 0; i < numval; i++)
195 ptr[i] = clamped_initval;
196 checkvalfloat = ptr[0];
202 for (i = 0; i < numval; i++)
204 checkvaldouble = ptr[0];
209 rterror(
"rt_band_reclass: Unknown pixeltype %d", pixtype);
218 checkvalint, checkvaluint,
219 checkvalfloat, checkvaldouble,
223 RASTER_DEBUGF(3,
"rt_band_reclass: width = %d height = %d", width, height);
227 rterror(
"rt_band_reclass: Could not create new band");
234 for (x = 0; x < width; x++) {
235 for (y = 0; y < height; y++) {
243 RASTER_DEBUGF(4,
"(x, y, ov, isnodata) = (%d, %d, %f, %d)", x, y, ov, isnodata);
249 if (hasnodata && isnodata) {
254 for (i = 0; i < exprcount; i++) {
285 ov < expr->src.max ||
299 if (!do_nv)
continue;
309 if (hasnodata && isnodata) {
322 nv = (((ov - expr->
src.
min) * nr) / or) + expr->
dst.
min;
328 else if (nv < expr->dst.max)
333 if (nv < expr->dst.min)
335 else if (nv > expr->
dst.
max)
357 RASTER_DEBUGF(4,
"(%d, %d) ov: %f or: %f - %f nr: %f - %f nv: %f" 361 , (NULL != expr) ? expr->
src.
min : 0
362 , (NULL != expr) ? expr->
src.
max : 0
363 , (NULL != expr) ? expr->
dst.
min : 0
364 , (NULL != expr) ? expr->
dst.
max : 0
368 rterror(
"rt_band_reclass: Could not assign value to new band");
int32_t rt_util_clamp_to_32BSI(double value)
uint32_t rt_util_clamp_to_32BUI(double value)
struct rt_reclassexpr_t::rt_reclassrange dst
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
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.
uint16_t rt_util_clamp_to_16BUI(double value)
void rt_band_set_ownsdata_flag(rt_band band, int flag)
struct rt_reclassexpr_t::rt_reclassrange src
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
int8_t rt_util_clamp_to_8BSI(double value)
int rt_util_dbl_trunc_warning(double initialvalue, int32_t checkvalint, uint32_t checkvaluint, float checkvalfloat, double checkvaldouble, rt_pixtype pixtype)
int rt_band_get_hasnodata_flag(rt_band band)
Get hasnodata flag value.
uint16_t rt_band_get_width(rt_band band)
Return width of this band.
uint16_t rt_band_get_height(rt_band band)
Return height of this band.
#define RASTER_DEBUGF(level, msg,...)
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.
uint8_t rt_util_clamp_to_4BUI(double value)
uint8_t rt_util_clamp_to_8BUI(double value)
int rt_pixtype_size(rt_pixtype pixtype)
Return size in bytes of a value in the given pixtype.
uint8_t rt_util_clamp_to_1BB(double value)
void rtdealloc(void *mem)
uint8_t rt_util_clamp_to_2BUI(double value)
float rt_util_clamp_to_32F(double value)
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
int16_t rt_util_clamp_to_16BSI(double value)