Grdinterpolate -E output units in m?

Hi all!

I’m using grdinterpolate to find values over a vertical cross section, however it seems like the X axis output units are being given in m? Is there a way to set it to be given in km?

The command line I’m using:

gmt grdinterpolate $ingrid -G$outgrid -E-80/-15/-5/-15+i100k" -T0/800/1

which gives me: x_min: 0 x_max: 8012484.78674 x_inc: 100.034767678

however, I know I’m measuring a range of 75 degrees ~ 8330 km, so it seems the output is in meters? Or am I doing something wrong?

I highly appreciate any help!

Thanks, Bruna.

*should I attach the input 3D grid?

No documentation taht says +i100k will be processed as km so it remains meter. Use grdedit to switch by 100 if you prefer that.

Thank you! I guess I got confused with the part:
If no units are specified we default to great circle distances in km (if geographic).
from the documentation and was trying to find a way to get to it.

Your solution unfortunately is leading me to another error. My GMT is not allowing me to call variables from netCDF files. If I use $mygrid?var for anything it gives me “Named variable does not exist in file”.

Ex: the grid I’m working on, from grdinfo
x_min: 0 x_max: 8012484.78674 x_inc: 111284.510927 name: longitude n_columns: 73

and if I try
gmt grdedit$mygrid?longitude it gives
grdinfo (gmtapi_import_grid): Named variable does not exist in file [v.-80.-15.-5.-15.grd?longitude]
[Session gmt (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)
[Session gmt (0)]: Error returned from GMT API: GMT_GRID_READ_ERROR (18)

I tested with other netCDF grids and still get the same error…

Thanks for the support!


?var actually only recognizes the named variables in z…

if anyone has any clue please help, I’ve tried everything!!

Yes. GMT has never let anyone access a coordinate array since most of the time there is none, just the scalars min, inc, max. Only grids or cube layers can be accessed.

grdedit -R... should be the way to go.

1 Like

You are right about that. Shall see what we are doing with units here.

1 Like

Perfect, this does the trick for now! Thanks a lot!!

For anyone with a similar problem, here is how I’m getting around:

#run your interpolate options for a cross-section
gmt grdinterpolate $ingrid -G$outgrid -E$lon1/$lat1/$lon2/$lat2 -T$zmin/$zmax/$zinc -fg
#calculate the max crossing distance and convert to kilometers
dmax=$(gmt grdinfo -C -Q $outgrid | awk '{print $3/1000}')
#reset the values in kilometers
gmt grdedit -R0/$dmax/$zmin/$zmax $ingrid