GMT tutorial for beginners

Utpal Kumar     2 minute read

The Generic Mapping Tools is widely used across Earth and Planetary and other fields of studies to process data and generate high quality illustrations. This post is first introduction to beginners for getting started in GMT.

Please note that recently GMT version 6 has been released but this post is focussed on GMT version 5. For readers interested in GMT 6, I recommend beginners to get started with pyGMT.

How to install GMT

In Ubuntu: sudo apt-get install gmt gmt-dcw gmt-gshhg

In Mac: brew install gmt

For other operating systems, check GMT website

Requirements:

Below is a list of examples, originally inspired from the GMT documentation. For successfully running the codes, the user need to fulfill following requirements:

  • Pre-installed GMT-5, check by typing gmt in terminal.
  • Pre-installed netcdf-5, check by typing ncdump.
  • Pre-installed ghostview package, check by typing gv.
  • Downloaded ETOPO1_Bed_g_gmt4.grd in the Data directory from the NOAA website.

Examples:

Readers can download the package containing all the following examples from here. The package consists of three directories: Data, Scripts and Figures.

  • The Data directory contains the data files required to run the scripts in the Scripts directory.
  • The Scripts directory consists of all the bash scripts for all the later examples.
  • The Figures directory consists of all the example plots from 1-24.

Linear Plots

This script contains commands for making basemap for linear projections including the log-log plot. It also explains how to add title, xlabel, ylabel, tick-marks, background-color to the plot.

Plotting maps with different projections

This example explains how to plot the Mercator projection, Alber’s projection, Orthographic projection, Eckert projection.

Plotting lines and symbols

This example explains the use of psxy command to plot the lines and symbols. It also contains the commands to plot the earthquake epicenter with colors representing depths and symbol size representing magnitude.

Customizing plots with texts

This example explains how to type texts onto the plots. The user can even type mathematical equations.

Contour lines in GMT

This bash example explains how to plot the contour lines using the command grdcontour. It also explains how to cut the large data set using the grdcut command and obtain the information about it using the grdinfo. It also explains how to do interpolation of data (nearest neighbour and spline).

Colorbars and colorscales

This example contains the description of how to make the cpt files, and plot the colorbars using psscale command. It also explains plotting the relief data.

Plotting NetCDF data in GMT

This example shows how to plot the multidimensional netcdf data in GMT.

Three dimensional plots: Mesh and Surface plots

This examples script includes how to plot the data as 3D plots using two methods: mesh plot, color-coded surface.

Leave a comment

distanceVsSeismogram

Plotting seismograms with increasing epicentral distance

How to plot the distance vs seismic waveforms?

hurricane-track

Plotting track and trajectory of hurricanes on a topographic map

How to plot the track or trajectory of a hurricane on a map?