Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to download a list of all countries on this planet from OSM. Also, for selected countries, I would like to have states and cities.

How can this easily be achieved? There must be an easier way that to download the whole planet and iterate through all nodes, ways and relation, checking for each whether it maches my criteria, I hope...

share|improve this question
    
For major world cities metro.teczno.com –  Mapperz Mar 29 at 22:32
    
Thanks, but that's not quite what I want. I don't need a few specific individual cities. Rather, I'd like to have the whole world, but not in detail. For a specific city, I just want to know that it exists, what its name is, where on earth it is, and in which country. I don't need neighborhoods, streets POIs etc. –  Michael Junk Apr 2 at 13:42

1 Answer 1

up vote 2 down vote accepted

Overpass API allows you to download only selected objects. For country borders, admin_level=2 should return the information you want:

<osm-script>
  <query type="relation">
    <has-kv k="admin_level" v="2"/>
  </query>
  <print mode="meta"/>
</osm-script>

This returns 302 border relations without all coordinates.

States and cities have higher admin levels according to the local administrative hierarchy.


Alternatively, you can query for nodes with place=country:

<osm-script>
  <query type="node">
    <has-kv k="place" v="country"/>
  </query>
  <print mode="meta"/>
</osm-script>

This returns 226 countries represented by a single point in the middle, including the coordinates.

share|improve this answer
    
Thanks! That seems to be a good resource. Unfortunately overpass-turbo.eu consistentenly times out. Any ideas? –  Michael Junk Apr 2 at 13:54
    
Try to load the relation without the border coordinates. Most countries have a lable point with place=country as you can see in my extended answer. –  Andre Joost Apr 2 at 15:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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