[GIS] Customizing OpenStreetMap “carto” style

mapnikopenstreetmap

I have been following the switch2osm tutorial explaining how to setup your own tile server:

https://switch2osm.org/manually-building-a-tile-server-16-04-2-lts

Everything works fine, however I would like to tweak a few things in order to better understand the rendering curtomization process. As a start I would like to change the color of the country bounderies from the default openstreetmap color to black. Also the bounderies are only displayed at low zoom levels (such as 3) but I would like to enable them at any zoom level.

My understanding is that this kind of styling is controlled by the Mapnik.xml file, which is in turn generated by the carto project.mml > mapnik.xml command.

How do I modify the project.mml or one of its dependent files in order to achieve my goals?

Best Answer

You can read up on the basics of CartoCSS starting at https://www.mapbox.com/help/getting-started-cartocss/#basic-cartoCSS.

The main reference documentation is at https://github.com/mapbox/carto/blob/master/docs/latest.md.

If you're OK with github, I'd clone https://github.com/mapbox/osm-bright and work from that. If not, its up to you whether to learn git or to work off the version you already have.

There is more than one option for most of the things you want to do, depending on how wide you want to go. As an example, you can change the admin boundary by modifying: @admin_2: #324; around https://github.com/mapbox/osm-bright/blob/master/osm-bright/palette.mss#L134 or you could change the line-color around https://github.com/mapbox/osm-bright/blob/master/osm-bright/base.mss#L164 (not the greatest example, but hopefully you can see that the palette change would affect every use of admin_2, but you could define a new substitution, hard code the value, or just update the value). You should be able to see something similar for extending render to other zoom levels (higher numbers).

Otherwise, I'd suggest trying it, doing a small render area, and updating. Cartography is mainly art, and there is no substitute for practice and experimentation.

Related Question