0

Is there any easy way to render all roads and paths with an equal width in Mapnik? In the rendition below, all lines have the same line width, but since many of the bigger roads have many lanes or parallel roads that are (nearly) overlapping, they seem fatter.

My source for Mapnik is a PostGIS database with OSM data.

Any ideas?

enter image description here

1

2 Answers 2

3

Take a look at Skeletron, which is a Python tool to merge adjacent lines.

(Incidentally, I came here via your request in #osm IRC, but it would be polite for you to wait there a little more than 30 seconds to see if someone has an answer to your question!)

1
  • Thanks! I'll check that out. Yeah, I'm sorry about that. I'm not very familiar with IRC, so I disconnected accidentally when I tried to join another channel.
    – meriri
    Commented Oct 6, 2015 at 18:38
1

You can define different line widths in mapnik with a filter e.g.

<Rule>
  <Filter>([type]='motorway')</Filter>
  <LineSymbolizer stroke-width="0.5" stroke="#000" />
</Rule>
<Rule>
  <Filter>([type]='primary')</Filter>
  <LineSymbolizer stroke-width="1" stroke="#000" />
</Rule>

To create more complex mapnik files I usually use Tilemill because I find CartoCSS easier readable and well documented. For more information consult the guide for styling lines and the CartoCSS reference.

An example for styling road lines could be:

#roads {
  [type='motorway']{
    line-width:.5;
    line-color:#168;
  }
  [type='primary']{
    line-width:1;
    line-color:#168;
  }
  [type='secondary']{
    line-width:1;
    line-color:#168;
  }
  [type='residential']{
    line-width:1;
    line-color:#168;
  }
}

After creating your map in Tilemill you can export the style as Mapnik XML which you can use then in your application.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.