Computing Information

Getting Started With GMT

GMT (The Generic Mapping Tools software package) was written by Paul Wessel and Walter Smith. If you use their software, you can reference it with:

Wessel, P., and W.H.F. Smith, 1991, Free software helps map and display data, EOS, Transactions AGU, 72:441, 445-446.

Check out the tuturial.

To run GMT, you need to add the following line to your .cshrc file (in your home directory):

set GMT

Also, you should copy the file /home/other/plates/.gmtdefaults into your home directory. If you have never used GMT, now would be a good time to find the manual around the Institute and read the Cookbook section, the GMTSYSTEM section, and the GMTDEFAULTS section. Then, you ought to start with some simple maps, like those generated by psbasemap and pscoast.

The way GMT works is that you write up a 'script' or command file consisting of GMT commands. Each command adds part of your map, e.g. coastlines, shiptracks, text. Once a command file has been made, you execute the command file and GMT processes the commands contained within it. For instance, say you created a GMT command file called gmt.com. To run it, first make sure it's an executable by: chmod +x gmt.com. Then execute the script by invoking it:
gmt.com

GMT outputs a PostScript file that you can send to the printer, lpr cruise.ps, or you can use Pageview to view it under OpenWindows. You can add labels etc. using GMT commands or by running IslandDraw and opening the GMT PostScript output file. You can put the PostScript file into your public folder on ignite and open it with Adobe Illustrator or import it into CorelDraw.

GMT has its own coastline files. GMT can read in a simple xy or xyz file. Pen up is indicated by ">". For example, below is a track line with longitude latitude.

>
172.55 -34.4
170.52 -37.58
163.417 -44.567
>
167.25 -42.75
167.667 -43.3
154 -48.462
154.133 -48.603
>
Below is an example of a GMT command file which makes a basemap with coastlines and overlays a shiptrack into an output file named cruise.ps. Comment lines begin with "#".
rm cruise.ps
#
# plot basemap
psbasemap -V -P -K -Jm.12 -R130/180/-65/-30 -Ba10f5 > cruise.ps
#
# plot the full resolution coastline and fill with black
pscoast -V -O -K -Df -Jm -R -G0/0/0 >> cruise.ps
#
# plot ship-track in red, suppress drawing as a great circle arc
psxy -V -O -Jm -R -M -W1/255/0/0 -A track.gmt >> cruise.ps
Many of the arguments for GMT commands are shared and get carried from one command to the next unless you change them.
Vverbose (prints what's happening to the screen)
P makes the map profile (versus landscape) view. Landscape is usually the default.
J projection. The letter after J says what kind of projection.
For instance Jm indicates Mercator. Jo is orthographic. The number 0.12 in this case means 0.12 inches per degree of longitude - the scaling changes with each projection.
R region (usually expressed as west longitude, east longitude, south latitude, north latitude).
B sets the tick mark variables. In the above example, it'll make a tick mark every 5 degrees, annotating every 10.
K means there are more commands to come, hence don't terminate the PostScript file (output PS file here is cruise.ps. A PS file is terminated by the phrase showpage).
O overlay this on the previous map (e.g. overlay the coastlines on the basemap).
G fill option (followed by red/green/blue. 0/0/0 = black; 255/255/255 = white; 255/0/0 =red; 0/255/0 =green; 0/0/255=blue).

Notes/bugs

  1. Setting the page size.
    You can set the page size either in your .gmtdefaults file:
    PAPER_MEDIA    size
    or as a gmtset line at the beginning of your script:
    gmtset    PAPER_MEDIA size
    where size is the paper size. The first column in the table below is the size you might enter; the second & third columns are the x & y size in points.
    sizex (points)y (points)
    A023803368
    A116842380
    A211901684
    A38421190
    A4595842
    A5421595
    A6297421
    A7210297
    A8148210
    A9105148
    A1074105
    B028364008
    B120042836
    B214182004
    B310021418
    B47091002
    B5501709
    arch648864
    archB8641296
    archC12961728
    archD17282592
    archE25923456
    flsa612936
    halfletter396612
    note540720
    letter612792
    legal6121008
    11x177921224
    ledger1224792

  2. psxy will sometimes bomb if your xy file starts with a single point followed by a pen-up (>) command. For example:
    13.55 -45.887
    >
    88.66 77.0909
    77.33 77.00
    >
  3. Printing a GMT PostScript file.
    If your PostScript file won't print, check to see if the file has 'showpage' at the end. If not, check your GMT command file and make sure that there is not a '-K' in the last line. Note that Pageview will still show the image even if it does not have a 'showpage' at the end.

  4. Scaling a GMT file in IslandDraw
    GMT puts an invisible 'bounding box' around each data file you plot on a map. This box sometimes won't allow you to change scale/size of the image in IslandDraw. To solve this, once you open your GMT PostScript file in IslandDraw, click on it and Ungroup it. Then try to scale. If it doesn't work, click Undo. Then click Ungroup again and try to scale.

  5. Printing a color figure from IslandDraw.
    Make sure you set the parameters in all four print windows. When you select Print only the first window shows up. You need to click the '+' button in the lower right to open the second. Once the second window is open, click the Printer setup button in the lower right to open windows 3/4. Make sure the appropriate color (PostScript bw or color) is set in both window 1 and 3 and that the size is set in both window 2 and 4.

  6. Printing a large figure to the HP plotters from IslandDraw.
    1. Have the figure at the scale you want it. (Note you can change the page size in IslandDraw under the Options in Menu Bar using the Setupbutton.)
    2. Under File, select the print button and make all appropriate selections as if you were printing (color and size in both places, see '3. Printing a figure...' above).
    3. Leave the print windows open and select 'Save As from under the Filebutton. In the 'Save As box, type a new name for the output PostScript file so it doesn't overwrite your IslandDraw document (e.g. file.ID.ps), click on other format and make sure it says Printer. Then save.

(Please send comments/corrections/questions/etc. concerning this page to lisa@ig.utexas.edu)