Académique Documents
Professionnel Documents
Culture Documents
A Beginners Guide
March 2014
1. Introduction 1
1.1. Required software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2. Optional software . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3. Installing Ghostscript and GSview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4. Installing GMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.5. DOS Batch files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
3. Examples 7
3.1. India - script modified . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2. Korea - Japan coast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
3.3. Japan Cities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4. Places I lived . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
3.5. North Arrow & Scale . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.6. North Arrow & Scale Extended . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.7. Inset map with extent rectangle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.8. Sampling stations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.9. Simple contour plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.10. Multiple Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Appendix 18
A. Quick reference 18
A.1. List of colours . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
A.2. PostScript fonts used by GMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
A.3. Chart of octal codes for characters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
A.4. Predefined bit and hachure patterns in GMT . . . . . . . . . . . . . . . . . . . . . . . 25
ii
List of figures
iii
CHAPTER 1
Introduction
What is GMT?
GMT is a set of programs that allows you to make plots and maps. These programs create Encapsulated
PostScript (eps) and Postscript (ps) output. On Windows you will need a viewer that supports such
(eps/ps) files. One such viewer is GSview, which allows eps and ps files to be viewed and printed.
A simple google search will take you to respective websites and you can download and install as any
other windows program (basic instructions are provided in the following sections).
GMT is developed and maintained by Paul Wessel and Walter H. F. Smith with help from a global
set of volunteers, and is supported by the National Science Foundation. It is released under the GNU
General Public License (http://gmt.soest.hawaii.edu/).
2. GSview
1
1.4. Installing GMT
1. Go to website http://gmt.soest.hawaii.edu/projects/gmt/wiki/Download
3. Install using the options as shown in the following screen shots (Figures 1.2 & 1.3).
2
Double-clicking the batch file executes the commands and gives the result (map).
3
CHAPTER 2
4
Explanation
The -R switch specifies the extent of the map we want to generate. Longitude values corresponds to
the x range and latitude values corresponds to the y range.
The projection is specified with the -J switch. In this example we used -JM12. This selects the
projection (Mercator) and sets the width of the map to 12 centimeters. UNIT of the width can be
cm, inch, or point. The default is centimeter, but this can be overridden on the command line by
appending c, i, or p to the width values (e.g. 12i).
Resolution (-D)
The -D switch selects the resolution of the data set used in creating the map. The available choices
are f, h, i, l, and c which correspond to full, high, intermediate, low, and crude. Here we used
the full resolution data set.
Shorelines (-W)
-W
The -W switch draw shorelines (Default is no shorelines).
5
National boundaries (-N)
Basemap (-B)
Set map frame and axes parameters. By default, all 4 map boundaries (or plot axes) are plotted
(named W, E, S, N). To customize, append the codes for those you want (e.g., WSn). Upper case
means plot and annotate while lower case just plots the specified axes.
The fill colour used for the countries is specified using the -G switch. The colour can be specified by
colour name, by a decimal colour code (r/g/b, each in range 0-255), or by a hexadecimal colour code
(see appendix A.1 for a list of some available colours).
The -P switch sets the page orientation to portrait. Landscape is the default.
6
CHAPTER 3
Examples
The default behavior of all GMT commands can be adjusted with the gmtset command. This com-
mand is usually used prior to any commands which produce output
del .gmtcommands4
del .gmtdefaults4
7
3.2. Korea - Japan coast
set output=Kr_Jp_coast.ps
set range=120/150/20/50
set scale=m1:25000000
gmtset BASEMAP_TYPE = plain
pscoast -Dh -R%range% -W1 -G200 -J%scale% -Ba10df5dg5d -L145/22:15/35/500 -P > %output%
del .gmt*
8
3.3. Japan Cities
del .gmtcommands4
del .gmtdefaults4
x y s a f j text string
9
3.4. Places I lived
line.txt
76.18 9.54
title.txt circle.txt
92.48 11.42
105 45 16 0 1 6 Places Lived 76.18 9.54
140.44 41.45
92.48 11.42
140.44 41.45
city.txt country.txt
76.18 9.54 10 0 1 3 Cochin 79 25.2 12 0 2 TR India
92.48 11.42 10 0 1 3 Andamans 146 33 12 0 2 TR Japan
140.44 41.45 10 0 1 3 Hakodate
10
3.5. North Arrow & Scale
pscoast -R%region% -J%prosca% -Df -L%scale% -W2 -N1 -G150 -K -P > %output%
echo 63.5 12 24 0 14 BL N | pstext -R -J -G0 -O -K >> %output%
echo 66 8 36 90 34 BL \343 | pstext -R -J -G0 -O -K >> %output%
psbasemap -R -J -B%bound% -O >> %output%
del .gmt*
Font 34 used in the pstext is the ZapfDingbats font. Other possible north arrows are: \324, \331,
\344, \352, \362, \363, \370. For more options see table A.3 on page 24.
11
3.6. North Arrow & Scale Extended
del .gmt*
12
3.7. Inset map with extent rectangle
Inset maps are used to provide either an overview of the area or a close up of a section or sections of
a map. Extent rectangles are a way to show the extent1 of one map within another map.
1
boundary
13
3.8. Sampling stations
set output=sampling_stations.ps
pscoast -R138/148/40/46 -Jm0.5i -B2 -P -W -Dh -K > %output%
psxy st01.txt -Sx0.15 -W2/255/0/0 -G0 -Jm -R -O -K >> %output%
psxy st02.txt -Sc0.15 -W1 -G0/0/255 -Jm -R -O -K >> %output%
psxy st03.txt -St0.2 -W1 -G0/255/0 -Jm -R -O >> %output%
del .gmt*
14
3.9. Simple contour plot
set file="D:\..\GMT\ETOPO1_Bed_g_gmt4.grd"
set output=contourAutumn.ps
gmtset PLOT_DEGREE_FORMAT F
MusashiBank.txt
140 44.85 18 0 3 CM Musashi Banks
141.9 43.94 18 0 3 CM Rumoi
15
3.10. Multiple Plot
16
Code for figure 3.10
set output=Multipleplot.ps
set range=0/100/-10/10
set size=7/4
set bound2=a20f10/a4f2WSne
set size=5/3
del .gmtcommands4
del .gmtdefaults4
data.txt
0.0 2.70
3.17 0.43
-2.10 -0.10
2.89 3.94
17
APPENDIX A
Quick reference
18
19
20
21
A.2. PostScript fonts used by GMT
GMT uses the standard 35 fonts that come with most PostScript laserwriters. If your printer does not
support some of these fonts, it will automatically substitute the default font (which is usually Courier).
The following is a list of the GMT fonts:
When specifying fonts in GMT, you can either give the entire font name or just the font number
listed in this table. For the special fonts Symbol (12) and ZapfDingbats (34), see table A.3.
22
A.3. Chart of octal codes for characters
Table A.2. Octal codes and corresponding symbols for StandardEncoding (left) and ISO-
Latin1Encoding (right) fonts.
23
Table A.3. Octal codes and corresponding symbols for Symbol (left) and ZapfDingbats (right) fonts.
24
A.4. Predefined bit and hachure patterns in GMT
GMT provides 90 different bit and hachure patterns that can be selected with the -Gp or -GP option
in most plotting programs. The left side of each image was created using -Gp, the right side shows
the inverted version using -GP.
25