mapnik-org/mapnik — Issue #356: suggestion for implementation of map borders and coordinate grids similar to those provided by GMT
Author: artemp
Created: 2011-10-11 07:51:21+00:00
State: open
Labels: Core_Library

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, http://gmt.soest.hawaii.edu) 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

http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node36.html
http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node37.html
http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node30.html

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

http://gmt.soest.hawaii.edu/gmt/doc/gmt/html/GMT_Docs/node78.html

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

Thanks!
Ulf

-----------------------------------------------------------
From:	Dane Springmeyer
To:	Ulf Mehlig
Cc:	mapnik-users@lists.berlios.de
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: http://mapnik-utils.googlecode.com/svn/example_code/bonne_projection/generate_graticules.py

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?

Dane

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

> I just saw that http://trac.mapnik.org/milestone/0.7.0 lists "map
> canvas
> 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 (http://gmt.soest.hawaii.edu), for example? That would
> be
> great ...
>
> However, is there any moderately simple way to get coordinate grids
> and
> map borders with coordinate division with today's Mapnik?
>
> Many thanks! Ulf