The result of grdtrack's -E option is strange

Hello. I am one of the gmt users.
While using grdtrack, the -E option gave different results than expected, so I posted this question.

gmt project -C126/42 -E146/40 -G0.05 | gmt grdtrack -G@earth_relief_04m

The above code extracts tracks in units of 0.05 degrees, as expected.

126     42      0       581.55078125
126.06727303    41.9992195957   0.05    685.950447216
126.134544368   41.9983999151   0.1     778.567266292
126.201813932   41.9975409602   0.15    738.711357089
126.269081639   41.9966427332   0.2     786.50699371
126.336347405   41.9957052366   0.25    775.874512494
126.403611148   41.9947284728   0.3     651.538325028
126.470872785   41.9937124444   0.35    606.330429786
126.538132233   41.9926571539   0.4     583.099983292
126.605389409   41.9915626042   0.45    637.451147242
...

However, the following code…

gmt grdtrack -E126/42/146/40+d+g+i0.05 -G@earth_relief_04m -fg

differs slightly from 0.05 degrees.

126     42      0       581.55078125
126.066454721   41.9992293247   0.0494906569467 682.709060635
126.132922972   41.9984201334   0.0989926135381 780.37441656
126.19940458    41.9975724033   0.148505799718  738.998673986
126.265899368   41.9966861117   0.198030145332  781.983636776
126.332407163   41.9957612361   0.247565580126  781.71866822
126.398927787   41.9947977546   0.29711203375   661.76110162
126.465461066   41.9937956454   0.346669435755  603.199805729
126.532006823   41.9927548871   0.396237715597  589.333642864
126.598564884   41.9916754585   0.445816802634  622.493582344
...

The two profiles are almost similar, but there are subtle differences.


The plot above was drawn using the following code.

gmt begin profile png
        gmt project -C126/42 -E146/40 -G0.05 | gmt grdtrack -G@earth_relief_04m >tmp1
        gmt grdtrack -E126/42/146/40+d+g+i0.05 -G@earth_relief_04m -fg >tmp2

        gmt plot tmp1 -R0/15/-8000/6000 -JX12c/3c -BWSrt -Bxa2f1 -Bx+lDistance -Bya4000 -By+l"Elevation / m" -W0.25p,red,solid -i2,3
        gmt plot tmp2 -W0.25p,blue,solid -i2,3
gmt end

I’m using Ubuntu 22.04 LTS, gmt is version 6.3, and I installed it via apt install.
Why is there such a difference between the two commands? How to use grdtrack’s -E option correctly?
Thank you.

Hi @tllc46! Welcome to the GMT forum.

I think that in the first command you are assuming that your input is cartesian while in the second your indicate that your input is geographic (-fg).

So, try this command (if your input is lont/lat).

gmt project -C126/42 -E146/40 -G0.05 -Q

Honestly, I’m confused with this too. I was expecting that both, although using different equations, would produce the same x,y locations (grdtrack -E by default also uses the spherical approximation).

project expects geographic coordinates and does spherical calculations only.

Yes, I was wrong.

Yes, I see. Thank you so much for your reply.