Hello,

I'm struggling to find info on how to generate maps with Mapnik (mml file) that only show the contour of states and counties for the US (for example), and everything else white or transparent.

Any pointer welcome. Thanks!

asked 07 Jul, 02:00

pat548's gravatar image

pat548
1013
accept rate: 0%

edited 07 Jul, 02:04

By contour do you mean height contours or just the administrative outlines?

(07 Jul, 20:37) InsertUser

I probably used the wrong word, I don't want height, just the country or state, or county, as a simple line, nothing else.

(09 Jul, 13:37) pat548

There is plenty of ways to achieve this. You should tell us a bit more about your goal, is it for a map on a website, is it for just a few counties, the all country? What have you tried so far?

(10 Jul, 09:43) yvecai

I just want to generate a PNG, with transparency, for either the whole US, with states, or a single state with counties. So far, I've tried modifying the project.mml file of the openstreetmap-carto project to only show those lines, but even with a single layer, it still show the ocean and there's no transparency:

Layer: - id: landcover-line geometry: linestring <<: extents Datasource: <<: osm2pgsql table: |- (SELECT way FROM planet_osm_line WHERE man_made = 'cutline' ) AS landcover_line properties: minzoom: 5

I guess my main problem is I can't find any good documentation about all the options I can use here. I've looked into the reference, but without examples, it's hard to follow.

(10 Jul, 14:23) pat548

Correction, the layer is actually:

Layer: - id: admin-low-zoom geometry: linestring <<: extents Datasource: <<: osm2pgsql table: |- (SELECT way, admin_level FROM planet_osm_roads WHERE boundary = 'administrative' AND admin_level IN ('0', '1', '2', '3', '4') AND osm_id < 0 ORDER BY admin_level DESC ) AS admin_low_zoom properties: minzoom: 4 maxzoom: 7

(10 Jul, 15:43) pat548

You have to set the background color of your map transparent, example in the xml:

In the style.mss, replace the @land-color by rgba(0,0,255,0)

Map {
  background-color: rgba(0,0,255,0);
}

At the end, the <map>tag in the xml generated should look like something like this:

<Map srs="..." background-color="rgba(0, 0, 255, 0)" > .. </Map>

permanent link

answered 11 Jul, 17:20

yvecai's gravatar image

yvecai
1.5k1226
accept rate: 9%

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "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:

×7
×337

question asked: 07 Jul, 02:00

question was seen: 252 times

last updated: 11 Jul, 17:20

powered by OSQA