Conference hashtag is #sotmeu





Pause café

Merci à

Stephan Bösch-Plepelits

pgmapcss - Advanced Cartography for Mapnik

Implementing MapCSS by Moving the Cartography Into the Database


pgmapcss combines MapCSS - a more or less standardized map description language - with Mapnik - a widely used map renderer for vector or bitmap maps. In contrast to other attempts at using CSS-like styling, the actual cartography process (evaluating which map features should be rendered in the current view and how) is moved into a database function (Using PL/Python3 in a PostgreSQL database). Mapnik just needs to read the final properties - e.g. geometry, widths, colors, texts, and so on. This database function is compiled by pgmapcss from the MapCSS style sheet.

There are many advantages to this idea:

  • Writing MapCSS simplifies writing style sheets for Mapnik, as there's no longer a separation into database query and styling. Often those database queries were complex and required advanced knowledge of SQL. pgmapcss takes most of the complexity away. In addition, the actual database queries for map features are optimized for each zoom level.
  • MapCSS is powerful because map features can be related to each other (e.g. by relation membership or the proximity of objects). Furthermore calculations are possible (e.g. show the width of a line based on the value of a tag of the map feature). pgmapcss even offers geometric calculations (e.g. create lines between map features, rotation, buffers, …).
  • As there are more than ten libraries which implement MapCSS, the language is available on different platforms and for different output media. Styles can be used with various libraries, although there are differences between dialects, but hopefully they will converge in the future.

About the author

Stephan Bösch-Plepelits is interested in computer science and urban planning. He started mapping in 2008, and in OSM his main projects are OpenStreetBrowser and pgmapcss. Stephan loves hacking.


Video/Audio recording: mp3 mp4 ogg WebM YouTube

Presentation slides

Mentions légales · Contact · Sponsors