Home CV Resources Research Conference Outreach The Art Space

Jyotirmoy's Home Page

Simple Visualisation

GMT is an open-source tool for visualising colourfull maps. This is widely used in Earth system science discipline. Many of the features are available in other software packages, like ArcGIS, but they are not free to use. Also, GMT can be combined with shell script, MATLAB, Python, Fortran which is more adavangtageous for people familiar with coding.

Install GMT

Recommended
Click GMT 5 Install Instructions for detailed descriptions.
Ubuntu users can install GMT 5 by pasting the following line in the terminal.

$ sudo apt-get install gmt gmt-dcw gmt-gshhg

For installing older version of GMT (4.18) please visit here.

GMT Basics

Recommended
Visit GMT documentation page for details.
Here, I will put some basic ideas for students who are not much into coding and could get lost in the huge data repository of GMT main page.

Plot Global Map

$ gmt pscoast -Rg -Jx0.025id -B30 -W1 > world.ps

Output
All GMT 5 script starts with "gmt". In older version this was not required.

pscoast

The command pscoast contains the data for global coastline. Visit pscoast page for detailed documentation.

-Rg

-R stands for the region of interest. g is global. So, -Rg will plot a global map.
If you are interested to plot Indian coastline, this option will be changed to -R60/100/0/40. These four numbers are longitude and latitudes in west/east/south/north format. Change these values and play with different maps.

-Jx0.025id

-Jx stands for the projection type. Jx is for retangular projection. 0.025id stands for size of the map. i is for inches and d is for diagonal. So, the map is 0.025 inches long along the diagonal of a rectangle. For global map, this dimension works well. You can try finding out how the map size changes by using different values. May try with -Jx0.2id, see how it changes!

-B30

-B stands for longitude latitude annotations. For B30, it will annotate the boundary for every 30 degrees. Change into -B60 and see.

What value of B will you choose for Indian map?

-W1

-W stands for thickness of coastline. Change it to W2 and see what happens.

world.ps

.ps is a postscript format. This can be converted to eps, jpg, pdf, tiff or png formats. GMT produces ps format files by default.

Map Projection



There are tons of GMT projection. Full details can be found in J option page. I will put some example of popularly used projections.

Mollweide projection (-JW)

$ gmt pscoast -Rd -JW8i -B30WeSn -Wred -Gblue > world.ps

Here -Rd will change the centre of the global map. Check how it comes.
Putting W(west) S(south) in capital and e(east) n(north) in small letters, the annotations will appear selectively only along the west and south margins.
Plot with different W and G options to see how they change the colour of map.

Mercator (-Jm)

$ gmt pscoast -R-170/-50/20/80 -Jm0.05i -B10WeSn -W2,brown -G0/168/170 -Sgray > NA.ps

In Marcator projection, check the distance towards pole in increasing. If the northern/southern latitudes are given as 90/-90, this projection will fail to produce any map.
-G is to select colour within coastlines. It can take colors like red/green/blue or can be specified from RGB colour values that comes in a format of 0-255/0-255/0-255. Change these values and see how the colour changes.
-S is to select colour outside the coastlines.
Here -Rd will change the centre of the global map. Check how it comes.
Putting W(west) S(south) in capital and e(east) n(north) in small letters, the annotations will appear selectively only along the west and south margins.
Plot with different W and G options to see how they change the colour of map.
The map looks very dirty because of lots of lakes in the continents? Try using -A1000 and see how it changes. Change the valus of A and check.

Try plotting Robinson projection, orthogonal projection after this.

Plot locations in GMT


Let's say, we want to plot a few locations in our map. Co-ordinate are given.
Asansol 23.6 86.9
Dhanbad 23.8 86.3
Maithon 23.7 86.7
Giridih 24.1 86.2
We can use psxy command to plot it. To do that, first create a map boundary.
$ gmt pscoast -R80/90/20/30 -Jx0.5id -B2 -N1 -K > location.ps
$ echo 86.9 23.6 | gmt psxy -Sc0.1i -Gred -Jx0.5id -R80/90/20/30 -B2 -A10000 -O -K >> location.ps

Scalar data plot

In Geophysics we want to plot physical quantities on maps. Physical quantities can be scalar, vector or tensor. For example, we might be interested in looking at what is the mean temperature on Earth surface. Here temperature is a scalar quantity. Using GMT, we can make such maps where different colous on map indiacte temperautre.
Here is an example how we can plot lithosphere thickness on a global map. I will use Conrad and Lithgow-Bertelloni (2006) lithosphere thickness data. The data is freely available from Clint Conrad's website. This data comes as ascii format. To plot a scalar field in GMT, we need to convert this ascii format to binary grid files.
gmt xyz2grd Conrad_GRL2006_liththick.dat -Rg -I1 -GConrad_GRL2006_liththick.grd

A new grid file has been produced named Conrad_GRL2006_liththick.grd which can be plotted in gmt. To do this, first we need to make a color scale which will cover the data range. For example, lithosphere thickness will vary from 0-300 km depth. So, we can make a color map from 0-300 with 5 km interval. This can be done using
gmt makecpt -T0/300/5 -Cseis > color.cpt

Sometimes, we may not know the range of grd file. We can easily find the range by using
gmt grdinfo $filename

Once we have the grd file and colormap (cpt) ready, we can plot that in a map. This will involve a few lines. Hence, it is recommended to use a text file and execute that file from terminal. Lines in the text file will be:
gmt pscoast -Rd -Jx0.025id - B30 -W1 -K > liththick.ps
gmt makecpt -T0/300/5 -Cseis > color.cpt
gmt grdimage Conrad_GRL2006_liththick.grd -Ccolor.cpt -R -J -O -K >> liththick.ps
gmt pscoast -R -J -B -W -O -K -A10000 >> liththick.ps

'K' in pscoast indiacte that the code will continue to next line. O in grdimage indiactes that the image should overlap with the previous map created by pscoast. In this line we do not need to specify the projection and co-ordinate again (R, J). They will be automatically called from the initially selected values. Once we use grdimage, it will cover the mapoutlines with image file. To plot the map, we can call pscoast again on top of the image.
We need to provide a colorscale to interpret the meaning of colors. This can be added by using psscale command
gmt psscale -4i/-0.45i/2i/0.2i -Ccolor.cpt -B50::/:'thickness (km)' -O -K >> liththick.ps

-4i/-0.45i/2i/0.2i represents y co-ordinate, x co-ordinate, scale length and scale width respectively. This can be changed accordingly. C calls the colormap which should be plotted. B is the annotation markers. B50 means annotations will be at every 50 km.

Vector data plot

updating

Combined data plot

updating