Definition at line 288 of file rt_pixel.c.
298 uint32_t dim[2] = {0};
299 double **values = NULL;
300 int **nodatas = NULL;
305 assert(npixel != NULL &&
count > 0);
306 assert(
value != NULL);
307 assert(nodata != NULL);
310 dim[0] = distancex * 2 + 1;
311 dim[1] = distancey * 2 + 1;
316 if (dim[0] != mask->
dimx || dim[1] != mask->
dimy) {
317 rterror(
"rt_pixel_set_array: mask dimensions %d x %d do not match given dims %d x %d", mask->
dimx, mask->
dimy, dim[0], dim[1]);
322 rterror(
"rt_pixel_set_array: Invalid mask");
329 values =
rtalloc(
sizeof(
double *) * dim[1]);
330 nodatas =
rtalloc(
sizeof(
int *) * dim[1]);
332 if (values == NULL || nodatas == NULL) {
333 rterror(
"rt_pixel_set_to_array: Could not allocate memory for 2D array");
338 for (i = 0; i < dim[1]; i++) {
339 values[i] =
rtalloc(
sizeof(
double) * dim[0]);
340 nodatas[i] =
rtalloc(
sizeof(
int) * dim[0]);
342 if (values[i] == NULL || nodatas[i] == NULL) {
343 rterror(
"rt_pixel_set_to_array: Could not allocate memory for dimension of 2D array");
345 if (values[i] == NULL) {
346 for (j = 0; j < i; j++) {
352 for (j = 0; j <= i; j++) {
366 memset(values[i], 0,
sizeof(
double) * dim[0]);
369 for (j = 0; j < dim[0]; j++)
374 zero[0] =
x - distancex;
375 zero[1] =
y - distancey;
378 for (i = 0; i <
count; i++) {
379 if (npixel[i].nodata)
382 _x = npixel[i].
x - zero[0];
383 _y = npixel[i].
y - zero[1];
390 values[_y][_x] = npixel[i].
value;
405 values[_y][_x] = npixel[i].
value;
412 if(mask->
nodata[_y][_x] == 1) {
418 values[_y][_x] = npixel[i].
value * mask->
values[_y][_x];
424 RASTER_DEBUGF(4,
"(x, y, nodata, value) = (%d, %d, %d, %f)", _x, _y, nodatas[_y][_x], values[_y][_x]);
428 *nodata = &(*nodatas);
void rterror(const char *fmt,...)
Wrappers used for reporting errors and info.
void * rtalloc(size_t size)
Wrappers used for managing memory.
#define RASTER_DEBUGF(level, msg,...)
void rtdealloc(void *mem)
References genraster::count, rt_mask_t::dimx, rt_mask_t::dimy, ES_ERROR, ES_NONE, FLT_EQ, rt_mask_t::nodata, RASTER_DEBUGF, rtalloc(), rtdealloc(), rterror(), rt_pixel_t::value, genraster::value, rt_mask_t::values, rt_mask_t::weighted, rt_pixel_t::x, pixval::x, rt_pixel_t::y, and pixval::y.
Referenced by RASTER_neighborhood(), rt_raster_iterator(), test_band_get_nearest_pixel(), and test_pixel_set_to_array().