Retrieve a point value from the raster using a world coordinate and bilinear interpolation.
1265 double xcenter, ycenter;
1266 double values[2][2];
1267 double nodatavalue = 0.0;
1274 uint16_t width, height;
1277 xcell = (int)floor(xr);
1278 ycell = (int)floor(yr);
1279 xcenter = xcell + 0.5;
1280 ycenter = ycell + 0.5;
1287 if(xcell < 0 || ycell < 0 || xcell >= width || ycell >= height) {
1288 rtwarn(
"Attempting to get pixel value with out of range raster coordinates: (%d, %d)", xcell, ycell);
1293 xdir = xr < xcenter ? 1 : 0;
1294 ydir = yr < ycenter ? 1 : 0;
1304 for (i = 0; i < 2; i++) {
1305 for (j = 0; j < 2; j++) {
1306 double value = nodatavalue;
1308 int xij = xcell + (i - xdir);
1309 int yij = ycell + (j - ydir);
1311 if(xij < 0 || yij < 0 || xij >= width || yij >= height) {
1324 values[i][j] =
value;
1325 nodatas[i][j] = nodata;
1330 if (nodatas[xdir][ydir]) {
1331 *r_value = nodatavalue;
1338 xr = xr - (
x[0][0] + 0.5);
1339 yr = yr - (
y[0][0] + 0.5);
1344 for (i = 0; i < 2; i++) {
1345 for (j = 0; j < 2; j++) {
1347 values[i][j] = values[xdir][ydir];
1354 *r_value = values[0][0] * (1-xr) * (1-yr) +
1355 values[1][0] * (1-yr) * xr +
1356 values[0][1] * (1-xr) * yr +
1357 values[1][1] * xr * yr;
void rtwarn(const char *fmt,...)
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.