Is there a way to add an offset to output columns?

Is there a way to add an offset to an output column like -i0+o1,1 does for input? I use mapproject to convert a fault trace from lon,lat to plot coordinates in cm using a mercator projection. I want to add an offset in cm to the projected plot coords. Getting an input offset with mapproject -I seems like it could run into issues. I can do it by piping the output of mapproject to awk (maybe gmtmath can do it, but I’m more familiar with awk) and am wondering if I can do it all in a single mapproject call.

# pseudocode that works:
gmt mapproject $RANGE $PROJ coords_lonlat.gmt | awk -v dx=0.5 '/^[#>]/{print;next} {print $1+dx,$2}' > coords_xy.gmt
# this doesn't work (input longitude is offset by 0.5 degrees before projection to plot coords):
gmt mapproject $RANGE $PROJ coods_lonlat.gmt -i0+o0.5,1 > coords_xy_bad.gmt
TLDR:

I’m trying to make a schematic figure of various rupture scenarios on a fault. For example, on a hypothetical fault with two sections, section 1 ruptures in scenario A, section 2 ruptures in scenario B, and section 1 and 2 rupture in scenario C. My schematic shows the three scenarios side by side by way of a small offset. In this case the fault is roughly north-south, so I just add an offset to the x-coordinate.

My working version of this schematic figure, below, skips mapproject and uses -X to shift the plot origin, but this approach gets messy when trying to include this as a subplot.

gmt v 6.4.0 installed on macOS via conda

No, but please open a feature request on GitHub

I think that you could use gmt convert instead of awk:

gmt mapproject $RANGE $PROJ coords_lonlat.gmt | gmt convert -i0+o0.5,1 > coords_xy.gmt

1 Like

Being implemented in a branch off the master. If you can build from that git branch then you could test it out and see if it works as expected.

Thanks Paul. I think Esteban opened an issue for this already: https://github.com/GenericMappingTools/gmt/issues/6053.

I’m not set up to build from source but have been meaning to try.

Well, I have implemented it in said branch so if you do build then please test.

Merged into master.

1 Like