[ Skip to content]

Science and Engineering at The University of Edinburgh

School of GeoSciences

Personal Home Pages

You are here: Home >> Home Pages >> Cliff Ford >> Python for GMT

Section Contents

Python for GMT

In case you are not familiar with GMT:

  • The Generic Mapping Tools package consists of a collection of programs for producing publication quality maps of scientific data.
  • Most serious users learn how to use the command line interface and work with shell scripts.
  • For those unfamiliar with shell scripts there is iGMT, a very good Graphical User Interface based on Tcl/Tk that should work on most platforms with this toolkit installed.
  • There are some on-line map-making services that use GMT to deliver copyright-free maps via a web form: try Online Map Creation and ODSN Plate Tectonic Reconstruction Service.
  • The School used to run a GMT-based map-making service for the benefit of undergraduates. Since that time dozens of good sites have become available for map provision, and even detailed Ordnance Survey maps of the UK can be obtained on-line.

So why might we need any other ways to use GMT? What we really want to do is access and visualise remote data sets via the internet. Python ought to be a good tool for this purpose because it is easy to learn and use, and applications can be developed relatively quickly.

Python

Python is a popular object-oriented language used for both standalone programs and scripting applications in a variety of domains.

from Learning Python by Mark Lutz and David Ascher

As a start I have developed a simple interface that would allow anyone so-inclined to develop a GMT based map-making service. I looked at two previous Python-GMT interfaces:

  • PyGMT: was developed by Magnus Hagdorn but did not work with GMT4 and development has stalled.
  • gmt.gmt by Jeffrey Whitaker. This had backward compatibility issues on my platform but was easily tailored to provide a base for future development.

This is an initial release of a package (glggmt) consisting of the files required to generate GMT maps via a web form and this documentation.

glggmt

The open source glggmt package consists of two python scripts, a web form and a set of images from the GMT documentation. It is experimental, so there is no elaborate installation mechanism. Just download and unpack the tarball, copy the files to the right places and, if necessary, tweak the web server installation.

glggmt.tar.gz

The tarball unpacks to a glggmt folder containing two subfolders: cgi-bin contains the Python scripts to go into the web server cgi-bin directory, and gmtforms contains one form and many supporting graphic files. The web form has a fair amount of Javascript to control the parameters that can be set for different projections (but no error or sensibility checking yet). You can try the form but without map output.

Setup Instructions

  1. You need a working GMT installation and a working Web Server on the same system. It ought to be possible to use different systems for the two services but I don't know how to do that yet.
  2. The web server needs configuration. On my Linux box in /etc/httpd/conf.d/gmtmaps.conf I have the following pointers to the components of my GMT installation:

    SetEnv GMT_SHAREDIR /home/ceford/gmt/share
    SetEnv GMTROOT /home/ceford/gmt/GMT4.2.0
    SetEnv NETCDFHOME /usr/local/netcdf
    SetEnv LD_LIBRARY_PATH /usr/local/netcdf/lib

    And don't forget to restart the web server after any changes.

  3. Copy the contents of the downloaded cgi-bin folder to your web server's cgi-bin directory.
  4. Copy the gmtforms folder to somewhere in your public_html tree.
  5. Point your browser at gmtforms/pscoast-sh.html and see what happens.

There is no support, but you are welcome to report any issues or suggestions.

© School of GeoSciences --- Last modified: 26 May, 2007 --- Page contact: