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


I would like to know the simplest way to extract coastlines and borders in OSM, so I can include it into a PDF or SVG.

vector map of the world (mercator projection)

Extra points for being able to access the names of those polygons in some way. Since the coastline data was at 350MB in december 2011, I'm guessing the osm data pretty hard to use.

This question is marked "community wiki".

asked 19 Jan '11, 02:14

emj's gravatar image

accept rate: 15%

edited 14 Dec '11, 10:19

Instead of downloading everything and then filtering you could also download the data selectively from one of the people that provide a service for this.

You could for instance use one of the XAPI-servers or the overpass api. Then you can render this extract with one of the renderers, e.g. Osmarender or Maperitive.

Be prepared that the resulting PDF (if vector) and SVG will become very big. For most usecases you might want to simplify the data before converting it (that's why the natural earth datasets might suit better your needs).

permanent link

answered 24 Oct '11, 19:05

dieterdreist's gravatar image

accept rate: 3%

edited 24 Oct '11, 19:12

I once had a comparable use case. You might try using osmfilter. The command was like this:

./osmfilter myMap.osm --keep="all boundary=administrative admin_level=2" >myMapjustBoundaries.osm.

This way you should end up with a file that contains only osm ways and osm relations that make up national boundaries. For coastlines you'd have to run it a second time with a different --keep filter and then merge the outcomesw with osmconvert.

Alternatively you could just download the polygon file for national boundaries at Cloudmade...

permanent link

answered 29 Aug '11, 14:16

_chan_'s gravatar image

accept rate: 0%

edited 24 Oct '11, 09:03

emj's gravatar image


It took me 20 minutes to do something similar with Great Britain on a couple-of-years-old laptop - I'd have thought that if you need to do this more than once or don't want to wait some hours, that another approach would be a better option.

(24 Oct '11, 15:08) SomeoneElse ♦

I'd suggest using Natural Earth's datasets for these kinds of things. It's already filtered for smaller-resolution usage and it is in public domain.

I'm using Natural Earth in my new project called Geosomnia, which will include the world map soon.

permanent link

answered 19 Jan '11, 05:37

Breki's gravatar image

accept rate: 10%


If your goal is getting a world political map into a SVG or PDF, then I suggest using Natural Earth, since it's much simpler to get a hold of. Using OSM data is fine, but be prepared to download and process 12 GB of compressed XML data + fixing any missing polylines in order to get proper polygons. So my answer is still Natural Earth. OSM data is much more interesting for other features which other sources don't have, like world-wide road network & similar. This is where it pays off to process such a big dataset.

(19 Jan '11, 12:17) Breki

I'm asking this question because I think it needs to be asked, if OSM is about the data then we should use it.

(19 Jan '11, 12:44) emj

I agree, but if I have a task to do, I usually pick the easiest solution to get it done. I'll use OSM data when it is best suited for the job, and drawing political boundaries on a 1 : 100M scale isn't one of these situations. My experience on how inconsistently boundaries are tagged in various parts of the OSM world tells me you'd have a pretty big task just to clean out things before you could even start preparing such a map. Here's an example of what we're up against: []

(19 Jan '11, 13:04) Breki

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: 19 Jan '11, 02:14

question was seen: 41,385 times

last updated: 14 Dec '11, 10:19

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