grdtrack with -T+e

Added by John 4 months ago

I'm having a little trouble getting the -T+e option on grdtrack to report what I expect. I updated to this morning's version of GMT, running on MacOS.

Attached is the grid file used. The grid goes from -R0/359.75/-90/90 on a 15 arcmin lattice (gridline mode).

When the following command is issued, the reported cell location and distance is not right. Is it user error, or is there something else going on?

> echo 220.779 0.0508 | gmt grdtrack -Gdac_dif_25125_00.nc -T+e
220.779 0.0508 -0.00787313 0 90 0

I expected the report to be: 220.779 0.0508 -0.00787313 220.75 0 6478.76. The interpolated value is what is expected, just the -T+e output is not what was expected.

Any help is much appreciated!


Replies (7)

RE: grdtrack with -T+e - Added by John 4 months ago

Maybe no one wants to touch this one? Or perhaps someone has tried it and found it to be nasty? Appreciate any help! Thanks!

RE: grdtrack with -T+e - Added by Paul 4 months ago

Less to do with want and more to do with time available.

RE: grdtrack with -T+e - Added by Paul 4 months ago

Also, the output is only useful if the original node is NaN, which is not your case here.:

-T If nearest node is NaN, search outwards to find the nearest non-NaN node and return it instead.
       Append +e to append 3 extra columns: lon, lat of nearest node and its distance from original node.

I agree that right now it randomly returns the corner of the grid (since no search takes places), but I assume you would want to distance from the input point to the selected node, regardless if there were Nans or not in the way?

RE: grdtrack with -T+e - Added by Paul 4 months ago

I have implemented this in a new pull request that has been merged into master. Give it a try.

RE: grdtrack with -T+e - Added by John 4 months ago

I understand that the -T option can be useful for cases where a NaN node is the nearest node. I'm pleased that it simply reports the distance to the nearest node, regardless of the presence of NaNs.

After updating, I get the following for the grid:

> echo 220.779 0.0508 | gmt grdtrack -Gdac_dif_25125_00.nc -T+e
220.779 0.0508 -0.00787313 220.75 0 0.0584948

This correctly reports the location of the nearest node. In this case, the units for the distance quantity is, apparently, in degrees (via simple Pythagorean calc).

For future readers of this thread, the distance can be precisely computed by feeding the original point and node point coordinates into mapproject. For example,

> echo 220.779 0.0508 | gmt grdtrack -Gdac_dif_25125_00.nc -T+e | mapproject -G+v+u+e -i0,1,3,4
220.779 0.0508 220.75 0 6478.76

giving the answer expected, in the original post.

RE: grdtrack with -T+e - Added by John 4 months ago

How did I forget? THANKS so much Paul, for the atention and finding that extra time to make the fix! I owe you a couple of hours! Or a couple of brews, whichever payment you prefer!

RE: grdtrack with -T+e - Added by Paul 4 months ago

I think -T0e+e should eliminate the mapproject stuff.

(1-7/7)