The GMT/Julia API Wiki

1 Introduction

The GMT/Julia API is now available. It requires GMT 5.3.1 or later, available via the main GMT Download page. If you didn't yet learn about Julia we recommend that you give it a look and you may be converted/convinced. On a first sight it looks quite similar to MATLAB, which makes the learning curve quite smooth. On a second sight, however, Julia will bite a bit more when one starts to explore all of its power, namely its type system.

2 Install

Contrary to the rest of the GMT products the Julia wrapper has to live in a Github repository. If you just installed Julia you will need to initialize the package manager system. You do that by issuing this command at Julia's shell (but see full docs at Julia Packages):


At this time the GMT Wrapper is not yet officially registered so you install it with


Now you are ready to start using GMT, provided the GMT shared libs and their dependencies are found. On Windows, the installer has set the GMT/bin directory in the system's path and everything work out of the box. On UNIX, you may need to add the GMT lib path to Julia (unless GMT and Julia were both installed by the same package manager). If you need to, add the GMT lib path with:

push!(Libdl.DL_LOAD_PATH, "/full/path/to/gmt5/lib")

To make this command permanent, add it to your ~/.juliarc.jl file (if don't have one yet, create it with a text editor).

3 Using gmt-julia

Currently, please see the Julia Wrapper discussion in the main GMT documentation for typical examples of how to use GMT from within Julia, including how to pass data to and from GMT. But just to give you an idea, to reproduce the CookBook example of an Hemisphere map using a Azimuthal projection, run

using GMT
gmt("pscoast -Rg -JA280/30/3.5i -Bg -Dc -A1000 -Gnavy -P >")

Note regarding the using GMT command: We need to do that to load the GMT.jl wrapper, and the first time it may take a little longer because it need to JIT compile the module’s code. The subsequent commands, however, will run at same speed as the command line calls to GMT. You can also place that command in your ~/.juliarc.jl file and fuggedaboutit.