Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey guys,
I've picked up an error in the handling of NaNs in the bilinearInt method for the extract method.
See the example below:
Here the expected bilinear interpolation between points all with value 100 should always stay at 100 but we dip down to 55, 145. A quick peek at the source code shows that the handling isn't linearly adjusting when a NaN is found and simply using the value 0.5 which can lead to problems say when (y - y2) happens to be very small or very large; see below
terra/src/extract.cpp
Lines 168 to 183 in 1820db4
I've implemented in the first commit a few tests which fail on the current version of extract with method = "bilinear" and then in the second commit I've added the linear/bilinear factor back in to fix this issue. All tests pass and personally I've been using this algorithm on rasters at work with good results.