Skip to content

suggestion for implementation of map borders and coordinate grids similar to those provided by GMT #358

artemp opened this Issue Oct 11, 2011 · 3 comments

2 participants

Mapnik member
artemp commented Oct 11, 2011

This enhancement suggestion was encouraged by Dane Springmeyer (see emails appended below).

Mapnik currently lacks a feature to easily generate maps with coordinate grids and map borders with coordinates. Coordinate grids/borders are obligatory e.g. for any scientific use of maps.

The Generic Mapping Tools (GMT, could serve as a model for the functionality to be achieved by implementing this feature. GMT comprises a set of command line tools producing postscript output from raster or vector data for a given map bounding box, map size/scale and projection; the data produced may be augmented by other tool's output to generate the final map. To draw an empty base map with frame and coordinate grids, the tool psbasemap may be used. The base map specification (given by command line arguments and/or via the GMT configuration file) includes

  • the type of map border (frame type "simple" or "fancy"),

  • the sides of the map where borders are to be drawn (N, W, S, E) and

  • the subdivision of the grid.

The map border may include separate, "primary" and "secondary" frames drawn next to each other (possibly not essential for mapnik).

The "fancy" map border consists of a chain of slim rectangles in contrasting colours (normally black and white) alternating with the tick marks; the "simple" map borders consist of a line with tick marks. Within the map, grid lines can be drawn, or grid line intersections can be marked by crossed short line segments.

Intervals for labels and tick marks of the map border and for the grid lines/marks within the map can be chosen independently. The units for the subdivision of the grid depend on the projection. The number format for the labels can be specified via format string within the range valid for the given projection. Further, label offset, font, font size, label colour and line width, type and colour can be specified.

The respective GMT documentation (with graphical examples) can be found at

Examples for maps produced with varying border/grid specifications for the different projection types are illustrated within subsections of

I hope that this description might help to implement the corresponding functionality in a future version of mapnik.


From: Dane Springmeyer
To: Ulf Mehlig
Subject: Re: [Mapnik-users] map borders, coordinate grid
Date: Thu, 9 Apr 2009 08:18:27 -0700 (12:18 BRT)

Hello Ulf,

No. The desire for map elements has been expressed and their has been

some interesting work in the experimental PDF branch, but there is no

timeline or distinct plan at this point.

I should probably move those items to the 1.0 milestone to avoid

confusion (done).

The easiest way to get grids on a Mapnik map would be to generate a

shapefile or graticules and render it as a layer. I've stashed a

graticule generator here if you are interested:

For a map border you could consider rendering a Mapnik map to the

Cairo Context (requires building Mapnik with Cairo), and then using

the Cairo C++ or Python bindings to draw borders.

Ulf, GMT tools have quite advanced features and I agree that it would

be excellent to think through similar features in Mapnik.

Ulf, could you create a trac ticket describing some of the GMT stuff

you would like to see?


On Apr 9, 2009, at 7:40 AM, Ulf Mehlig wrote:

I just saw that lists "map

features (surround,legend,scalebar,etc)". Does this imply that one may
expect that future Mapnik versions provide different types of map
borders with coordinate divisions, scalebars etc., like in the Generic
Mapping Tools (, for example? That would

great ...

However, is there any moderately simple way to get coordinate grids

map borders with coordinate division with today's Mapnik?

Many thanks! Ulf

Mapnik member
artemp commented Oct 11, 2011
Mapnik member
artemp commented Oct 11, 2011

[cgs_bob] Here is another link that might be helpful to this ticket: []

@springmeyer springmeyer closed this Sep 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.