GMT: Changing the color of a symbol within a xy file

This is a very specific problem with Generic Mapping Tools which I didn’t find well documented: if you map certain symbols to a list of coordinates specified in COORDINATES.xy, you can specify that subsets of those coordinates are mapped to symbols in different colors in two ways:

  1.  You add a column containing numerical values that map to colors in COLORS.cpt. This option is illustrated in my earlier post on making WALS maps.
  2. You add coloring instructions directly to your COORDINATES.xy file by adding a line such as > -Gred. The hard-to-find part here was the fact that you need to prefix the color option by >.

In this case, your COORDINATES.xy file might look like this:

8.74, 9.72
11.80, 29.28
-8.65, 141.52
66.40, 17.43
70.67, 130.91
-29.71, 19.08
43.50, -88.50
-2.91, -68.91
42.04, 43.99
-10.61, 150.73
> -Gwhite -Wblack
56.80, -120.35
-13.81, -65.63
7.60, 6.04
> -Ggray -Wblack
-16.27, 168.01
-16.17, 168.14
-16.31, 168.05
-17.70, 168.38
-15.43, 167.24

You can then use this file, for example, with the following commands to produce a world map displaying these coordinates:

pscoast -R-20/340/-70/80 -Dl -A100/0/1 -JQ9.5i -W -B -K >
psxy COORDINATES.xy   -R -J -O -Sc0.25c -i2,1 -Gblack >>

The result looks like this:

Pretty WALS maps

A pretty map with WALS data, generated by GMT
A pretty map with WALS data, generated by GMT

The World Atlas of Language Structures maps data from typological studies to a world map. In addition to the online version, there is also a program for the local production of maps.

An even prettier map, in SVG format, with the background customised in Inkscape
An even prettier map, in SVG format, with the background customised in Inkscape

However, the options for customisation are limited. I use the free and open command-line tool GMT for the production of linguistic maps. It has awesome tools for all kinds of tasks, including the mapping of symbols from a file of coordinates. Here is a quick guide on how to produce your own pretty WALS map.

  1. Download your data set from WALS in tab-separated values (there is a button just underneath the header). Save it as walsXY.xy, where XY is the WALS feature you want to map.
  2. Remove the metadata lines at the top of the file and the header of the table.
  3. GMT does not distinguish between tabs and other simple blanks. Replace all simple space characters by nothing or a character of your choice.
  4. Start GMT and move to the directory to which you have downloaded your data set and where you want to produce your map.
  5. In the same folder, create a cpt file containing the colors that you want to assign to different values. My wals.cpt file has the following content: (number of WALS value, RGB values).
    1 240/11/0 
    2 0/210/240
    3 240/180/0
    4 28/142/59
    5 28/54/142
    6 90/28/142
    7 211/211/170
    8 0/0/0
  6. Run the following commands in GMT:
    pscoast -R-180/180/-70/80 -JQ7i -K -Ssteelblue >
    psxy walsXY.xy -R -i5,4,2 -J -O -Sc0.15c -Cwals.cpt >>
  7. For more options, see the documentation of GMT.