-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Hello,
While I was working on allowing different source and target coverage, I was a little puzzled by the bilinear interpolation option. As it seems to me now, it's not interpolation between the midpoints of the cells, but rather the edges of the grid.
For example, from one of the tests:
def test_interpolation_linear(self):
self._test_upsample_2d([[1., 2., 3.]],
5, 1, gtr.US_LINEAR, -1.,
[[1, 1.5, 2, 2.5, 3]]),Personally, I would have expected an output of [[1. 1.4 2. 2.6 3. ]], that is, assuming the midpoint is the point to measure from. In picture form, it's the difference between:
Marker = data
Solid = nearest
Dashed = linear interpolated
Linear interpolation from edges:

Linear interpolation from midpoints:

The bottom way of interpolating feels more consistent to me: it doesn't matter where the cell is located, the point "where to interpolate to" doesn't move on the x-axis.
I'm asking also because of the pull request: if source and target bounds don't line up, what's the consistent way of doing bilinear interpolation?
It's a few lines modification to change it to midpoint linear interpolation, but there's probably a reason for the current implementation I'm missing?