Retrieve a point value from the raster using a world coordinate and bilinear interpolation.
1416 double xcenter, ycenter;
1417 double values[2][2];
1418 double nodatavalue = 0.0;
1425 uint16_t width, height;
1428 xcell = (int)floor(xr);
1429 ycell = (int)floor(yr);
1430 xcenter = xcell + 0.5;
1431 ycenter = ycell + 0.5;
1438 if(xcell < 0 || ycell < 0 || xcell >= width || ycell >= height) {
1439 rtwarn(
"Attempting to get pixel value with out of range raster coordinates: (%d, %d)", xcell, ycell);
1444 xdir = xr < xcenter ? 1 : 0;
1445 ydir = yr < ycenter ? 1 : 0;
1455 for (i = 0; i < 2; i++) {
1456 for (j = 0; j < 2; j++) {
1457 double value = nodatavalue;
1459 int xij = xcell + (i - xdir);
1460 int yij = ycell + (j - ydir);
1462 if(xij < 0 || yij < 0 || xij >= width || yij >= height) {
1475 values[i][j] =
value;
1476 nodatas[i][j] = nodata;
1481 if (nodatas[xdir][ydir]) {
1482 *r_value = nodatavalue;
1489 xr = xr - (
x[0][0] + 0.5);
1490 yr = yr - (
y[0][0] + 0.5);
1495 for (i = 0; i < 2; i++) {
1496 for (j = 0; j < 2; j++) {
1498 values[i][j] = values[xdir][ydir];
1505 *r_value = values[0][0] * (1-xr) * (1-yr) +
1506 values[1][0] * (1-yr) * xr +
1507 values[0][1] * (1-xr) * yr +
1508 values[1][1] * xr * yr;
void void void rtwarn(const char *fmt,...) __attribute__((format(printf
rt_errorstate
Enum definitions.
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_get_nodata(rt_band band, double *nodata)
Get NODATA value.
uint16_t rt_band_get_height(rt_band band)
Return height of this band.