Skip to content

Commit

Permalink
use GDALRasterBand::InterpolateAtPoint() if GDAL >= 3.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edzer committed Oct 16, 2024
1 parent f0eb794 commit 395fef6
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/stars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -778,13 +778,19 @@ NumericMatrix CPL_extract(CharacterVector input, NumericMatrix xy, bool interpol
if (iPixel < 0 || iLine < 0 || iPixel >= xsize || iLine >= ysize) // outside bbox:
pixel = NA_REAL;
else { // read pixel:
#if GDAL_VERSION_NUM >= 3100000
if (poBand->InterpolateAtPoint(Pixel, Line, interpolate ? GRIORA_NearestNeighbour : GRIORA_Bilinear, &pixel, nullptr) != CE_None)
// tbd: handle GRIORA_Cubic, GRIORA_CubicSpline
stop("Error in InterpolateAtPoint()");
#else
if (interpolate)
// stop("interpolate not implemented");
pixel = get_bilinear(poBand, Pixel, Line, iPixel, iLine,
xsize, ysize, nodata_set, nodata);
else if (GDALRasterIO(poBand, GF_Read, iPixel, iLine, 1, 1,
&pixel, 1, 1, GDT_CFloat64, 0, 0) != CE_None)
stop("Error reading!");
#endif
if (nodata_set && pixel == nodata)
pixel = NA_REAL;
else if (dfOffset != 0.0 || dfScale != 1.0)
Expand Down

0 comments on commit 395fef6

Please sign in to comment.