I want to get OSM polygon shapes (GEOJson or WKT) of countries and cities only. I know that it is called a "relation" in OSM and each relation has its own id (New York is 175905, for example). How may I get a list of ids of all existing city and country relations in OSM? Is there same standard like numbers from 50.000 - 100.000 are countries and numbers from 300.000 - 500.000 are cities?

The best is to have something like a table:

OSM relation id | area name | type
175905          | New York  | city
1403916         | France    | country

3 Answers 3


Export of boundaries as various formats (shp, geojson, etc.) is possible using https://wambachers-osm.website/boundaries/ . It requires OAuth login with an OSM account.

You will find a list of defective boundaries at https://wambachers-osm.website/index.php/projekte/internationale-administrative-grenzen/missing-boundaries and the subpages. These are used as a quality improvement tool.

Disclaimer: It's not my tool.

  • Tool does not work anymore.
    – zabop
    Nov 22, 2022 at 12:34

What you are asking for are shapes of (unbroken!) boundary relations from places.

Some preprocessed shapes can already be downloaded here: http://download.geofabrik.de/europe.html
Another way is to get it via the wikipedia articles: http://wiki.openstreetmap.org/wiki/WIWOSM

But the manual processing isn't that easy:

  1. Determine OSM boundary relation ID (boundary level varies for different countries)
  2. Get all the child ways of the relation and check if the boundary is closed
  3. (fix broken relations manually and please submit this fixes back to OSM)
  4. Export this polygon as shapefile

Using an planet extract, the steps can be done using boundaries.pl and shp export scripts.


I have done this job (the 3 steps, but instead of shape format, I have prefer CSV/TSV format ), it will be available in the beginning of 2014 (PBF files are already available).

I have extract POIs, Cities, Streets and house numbers for each countries in CSV. It took me 4 months to get correct data and understand the multiple conditions to include.

the shape are in HEXEWKB, all the informations on the several fields are in the format file

Hope it helps.

The server is download.gisgraphy.com.

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.