How to find the data in the nearest grid point?

I have some ship track based data missing one of the variables (Var1) that I want to extract from a gridded database (1 x 1 degree).

At one location of my ship track, there will be 4 grid points (Left up, left down, right up and right down). Sometimes, 1 to 3 of them can be NaNs when they are close to land near the coastline. Is there a way I can quickly find the order of the distance between my data point and these 4 points? That way, I can use the one with the shortest distance that is non-NaN.

Many thanks!

1 Like

man of no faith
See grdtrack T option

To be used with normal grid sampling, and limited to a single, non-IMG grid. If the nearest node to the input point is NaN, search outwards until we find the nearest non-NaN node and report that value instead. Optionally specify a search radius which limits the consideration to points within this distance from the input point. To report the location of the nearest node and its distance from the input point, append +e .

1 Like