Grdvector rotation with projection

I have a grd file with East and North component velocities which plots like so (note, e.g., direction of vectors in PAC rel. NAM) in Mercator projecction

When I use oblique Mercator instead, it seems the velocities are not rotated correctly

I was under the impression that the -T option would handle this, but the relevant call line is this

grdvector $datadir/plates/morvel.vx.0.25.$pfix.grd
$reg $proj -O -K -T
-Q$vsize -Gwhite -W0.5 -I3 -Si$scale >> $ofile

Is this incorrect use, or a bug, or a feature?


The docs says that -T is for Cartesian data, which is not what you have. I made a simple test with a single-point grid and it seems to plot in the right direction in both plain mercator and oblique. If I try adding -T I get

grdvector [ERROR]: -T does not apply to geographic grids - ignored

Here is my simple test:

# Make a simple vector set with dx = dy = 1
echo -125 40 1 | gmt xyz2grd -Gx.grd -R-130/-120/35/45 -I5
echo -125 40 1 | gmt xyz2grd -Gy.grd -R-130/-120/35/45 -I5
gmt begin merc
	gmt coast  -R-130/-120/35/45 -JM6i -Bafg5 -Glightgray
	gmt grdvector x.grd y.grd -S1d -Gred -W2p -Q0.5c+e
gmt end show
gmt begin obl
	gmt coast -R135W/45N/115W/35N+r -JOa120W/25N/150/6i -Bafg5 -Glightgray
	gmt grdvector x.grd y.grd -Si2d -Gred -W2p -Q0.5c+e
gmt end show

Yeah, I wasn’t sure what that was meant to imply, but I get the same (wrong) orientation of vectors if I leave out the -T, forgot to mention that.

Come to think of it, given that I do not get that error message, it would seem that my grd files are not recognized as geographic? I did try adding -fg, but no dice.Also, grdinfo does report “Geographic grid”, but I am not seeing the error with the -T you get.

Yes, that is a bit odd. I am running off gmt master. If you do a suitable grdcut off your two grids and stick them into my script, do you still get the wrong result? If so, might you post those two small grids so I may have a failing test to examine?

Thanks! It seems to be the -S part, if I do not add a “d” or similar like you did in your script, i.e. if I use -S$x or -Si$x with x some number, the vectors don’t get rotated right. Note that I am using the old school vector spec with -Qa/b/c (see other post…). When I add a “d” to the -S, not only are the vectors oriented right, but they also somehow switch to the new vector look. However, it does not seem like it’s the vector type - when I use new style vectors without anything like the “d” for the S option, I likewise do not get rotations.

If one has to specify something like “d” for the rotation (why?), how do I get a vector length label? Usually, I use grdvector with -Sscale and then a psvelo with -Se(1/scale) for this purpose.

OK, I see that now. I will have a look and learn why. Clearly the ‘d’ (or any other geographic unit) will trigger “geographic” but it should already do that given -J…

Right, seems like that could be the issue. Thanks!

Thanks again, now (hopefully) fixed in master.

Excellent, thanks!