Use of grdtrack

Hello Professors and Seniors
I have tried to use grdtrack for the past three days but to no avail. I have my grd data (400_1_4_2_400.grd) as well as my xyz data (heatflow.xyz) that I want to use for sampling at every 10km. I want to use my grd data to track and sample some locations on my xyz data.
I tried to use many different parameters but to know avail.
One of the script I used is this
gmt grdtrack -G400_1_4_2_400.grd heatflow.xyz -Af -E93/-20,109/-1+i10u+d -R93/109/-20/-1 > heat.xyz
Another script is
gmt grdtrack -G400_1_4_2_400.grd heatflow.xyz -Af -E+o+d+i10u+l -R93/109/-20/-1 > heat.xyz
and also this out of many trials
$ gmt grdtrack -G400_1_4_2_400.grd heatflow.xyz -Af -E+oaz+d+i10ku+lu -R93/109/-20/-1 > heat.xyz
.
How can I use this gmt function to track and sample my grd data on the xyz data using a 10km sampling interval.
Many thanks Sir.

You cannot both specify a track to sample with -E and a track file to sample (heatflow.xyz). If as you say you want to sample the grid at the locations in the heatflowfile then no -E. If, on the other hand you wish to create sampling along a line every 10 km then use -E and specify +i10k. Your u unit is “survey foot”.

many thanks Prof. Sir, if I may ask based on your reply, what I wish to do is to sample the grid at the locations in the heatflowfile, what script must I use, because I haven’t used this GMT function grdtrack before until three days ago that I have been battling on it?

Sir, on the other hand if I wish to sample a line every 10km on my data , what script is to be used . This grdtrack function looks much complicated function to me in gmt. A friend just hinted me to use grdtrack.
Many thanks Sir.

Probably something like this to sample the grid at the heatflow locations

gmt grdtrack -G400_1_4_2_400.grd heatflow.xyz > heat_and_grid.xyz

Probably something like this to create line from coordinates and sample the grid every 10 km along the line. Here I am just picking a start and stop point for the line since I don’t know what you want so I picked a line from (95,3) to (105,-6):

gmt grdtrack -G400_1_4_2_400.grd -Af -E95/3/105/-6+i10k > grid_samplings.xyz

Prof. many thanks for your reply Sir, am grateful.
Sir the second gmt function returned an output but the first which is the very thing I want to do (i.e. sample the grid at the heatflow locations) did not show any result, I also went further to add other flags but still no result, what can I do to get the sampling done?

Hard to guess, but if you run

gmt grdinfo 400_1_4_2_400.grd
gmt gmtinfo heatflow.xyz

and post the output here then we will know a lot and can probably answer the question.

ok Sir, for the grd data, here is the grdinfo
image
while the gmtinfo for the xyz did not come up or did not display anything, but here is a sample of the content in the xyz file,
image
Sampling the grid data at the heatflow location is the issue now
Many thanks Sir.

Three things from what I can see:

  1. Your heatflow.xyz file has a header records that does not start with “#”. Either add that leading character or use -hi1 to indicate skipping one record of arbitrary text. gmt info should then work.
  2. Without the gmt info output I cannot say for sure, but the little bit of heat flow records you show are all outside your grids domain (which is south of Equator).
  3. It looks like your grid is geographic degrees but it was not created that way (for instance, it says the name for x-coordinates is “x”, not “degrees_east”. Depending on how you or someone else made that file they forgot to add -fg or use -R93E/109E/17S/1S in the region to tell GMT this is geographic data.

If you can recreate the grid and add -fg when you do so, then that helps GMT to know what the data is. Also, add the comment (#) to your headflow header so it can be skipped.

Many thank Prof. I have done the corrections to the data as you have instructed, here is the information from the grid and the xyz data.


Here is the details Sir.

and do the two commands I gave your work now then?