Generic Mapping Tools (GMT) is an excellent set of command line tools for dealing with spatial data and creating maps. If you’re using Fedora or openSUSE you can easily install the latest version using
zypper. However, the latest version on the Debian and Ubuntu repositories is 4.5.7 which is almost 2 years old. If you want the latest version, you need to compile it from source. Here is how.
First, open the console/terminal and type in:
sudo apt-get install libnetcdf-dev
Put in your user password (you have to have administrator’s rights for that) and proceed. This will install some libraries that GMT needs to run.
Next, get the install script and make it executable:
chmod +x ./install_gmt.sh
Now point your web browser to
Keep everything on default, except:
A.3. YES. Use file locking
C.1. My experience shows that the NOAA server is the fastest, and the European mirrors are dreadfully slow.
C.5. Shared (dynamic) Libraries
C.8. Place GMT in subdirectories of: /usr/local
If you know that you need something else, feel free to change it. Now click the GET PARAMETERS button and save the file to wherever your
install_gmt.sh file is (use
pwd if you’re not sure).
The final step is to run the installation. Type:
sudo ./install_gmt.sh GMT4param.txt
This will take a while. The first step that it does is downloading the files so you probably won’t see any progress. When it’s done it will give a message about adding something to PATH. You can ignore it. However, you might want to take the advice on adding the GMT documentation to your browser bookmarks. It’s much easier to use that instead of the terminal based manpages. To verify that it’s working, type in:
If it gives you an error, then something probably went wrong somewhere. Otherwise, you’re good to go.
The most convenient way to view graphical output of GMT is to use
ps2raster and convert it to your favourite format (pdf, png, jpg). However, if you want to view the ps/eps files directly, you need a document viewer. For Kubuntu (and other KDE based distributions) you can use Okular which is excellent. However, the default viewer on GNOME is Evince. Evince has a bug that it will not display patterns made using the
-Gp option. You will need to install gv then:
sudo apt-get install gv gsfonts-x11