NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum


I'm trying to render tiles with a very simple stylesheet. For data feed I'm using OSM file extract from the planet dump. I've read Mapnik can handle OSM XML files with some limitations.

There are two problems:

  1. Long ways are not rendered.
  2. All ways are distorted or displaced.

You can see the result here: At least the big roads in these two layers "Roads" and "Roads tiles" should match.

The second one seems like a projection problem and I tried tons of different variants but in vain. Here is my latest stylesheet: I've tried also simplier things for srs - "+proj=merc +datum=WGS84" and "+proj=latlon +datum=WGS84". I think the data from the planet dump extract is in latlon projection, but something is not right...

I would really appreciate some insight.

asked 04 Jun '12, 17:45

ivanatora's gravatar image

accept rate: 7%

edited 04 Jun '12, 17:54

When rendering with Mapnik, you have an input projection and an output projection. The input projection is what your data is in, and has to be given in the <Layer> element. The output projection is what you want your map to be in, and is usually given in the <Map> element (but some client programs e.g. allow you to override that).

You likely want your map in Google Mercator projection so your <Map> element

<Map bgcolor="transparent" srs="+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over">

looks ok (but try writing srs="+init=epsg:3857" which should also work and is clearer).

Your <Layer> elements claims that the source data is in Mercator as well, but it isn't; this will lead to distorted rendering. Your source data, raw latitudes and longitudes from OSM, is in EPSG:4326, so you'll need something like this:

<Layer name="highways" status="on" srs="+init=epsg:4326">
permanent link

answered 04 Jun '12, 18:37

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

edited 29 Mar '17, 23:03

Yep, it does make sense in that way and that was the problem. Thank you!

(05 Jun '12, 15:01) ivanatora

@frederik-ramm I'm a little late to the party but the code above should be srs="+init=epsg:4326" shouldn't it?

(29 Mar '17, 22:12) k-nut

Indeed, I modified the answer. Thanks.

(29 Mar '17, 23:03) Frederik Ramm ♦

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 04 Jun '12, 17:45

question was seen: 15,518 times

last updated: 29 Mar '17, 23:03

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum