A modern Python interface for the Generic Mapping Tools

Leonardo Uieda, Paul Wessel



The poster presented at the meeting.

This is the second conference presentation about my work on GMT/Python. The first was my talk at Scipy 2017. I mostly made progress establishing the basis for the software: documentation build, CIs, and the code to talk to the C API.

I hadn't presented a poster in 3 years and I really enjoyed designing this one. The background image was generated using GMT/Python (see the code in the poster). It's a clean design and I like how it turned out.

There is an online demo in a Jupyter notebook running on the mybinder.org service: agu2017demo.gmtpython.xyz

I don't know how long this demo will last and it might be down in the future. The demo is based on the Jupyter notebook that is in the accompanying Github repository. You can always download it and run locally or view it online.


Figures generated by The Generic Mapping Tools (GMT) are present in countless publications across the Earth sciences. The command-line interface of GMT lends the tool its flexibility but also creates a barrier to entry for beginners. Meanwhile, adoption of the Python programming language has grown across the scientific community. This growth is largely due to the simplicity and low barrier to entry of the language and its ecosystem of tools. Thus, it is not surprising that there have been at least three attempts to create Python interfaces for GMT: gmtpy, pygmt, and PyGMT. None of these projects are currently active and, with the exception of pygmt, they do not use the GMT Application Programming Interface (API) introduced in GMT 5. The two main Python libraries for plotting data on maps are the matplotlib Basemap toolkit (matplotlib.org/basemap) and Cartopy (scitools.org.uk/cartopy), both of which rely on matplotlib (matplotlib.org) as the backend for generating the figures. Basemap is known to have limitations and is being discontinued. Cartopy is an improvement over Basemap but is still bound by the speed and memory constraints of matplotlib. We present a new Python interface for GMT (GMT/Python) that makes use of the GMT API and of new features being developed for the upcoming GMT 6 release. The GMT/Python library is designed according to the norms and styles of the Python community. The library integrates with the scientific Python ecosystem by using the “virtual files” from the GMT API to implement input and output of Python data types (numpy “ndarray” for tabular data and xarray “Dataset” for grids). Other features include an object-oriented interface for creating figures, the ability to display figures in the Jupyter notebook, and descriptive aliases for GMT arguments (e.g., “region” instead of “R” and “projection” instead of “J”). GMT/Python can also serve as a backend for developing new high-level interfaces, which can help make GMT more accessible to beginners and more intuitive for Python users. GMT/Python is an open-source project hosted on Github (GenericMappingTools/gmt-python) and is in early stages of development. A first release will accompany the release of GMT 6, which is expected for early 2018.


Uieda, L., & Wessel, P. (2017). A modern Python interface for the Generic Mapping Tools. In Eos Trans. AGU (Abstract IN51B-0018).

Article Level Metrics

Comments? Let me know on Twitter (tweet @leouieda).
Found a typo/mistake? Send a fix through Github. All you need is an account and 5 minutes!

Related pages