Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting all cities in a specific country using OpenStreetMap

I've trying to find a way to use the OpenStreetMap API to get a list of all cities in a specific country with their longitude, latitude for an iOS app to develop.

However I been unable to do so. I've been trying to use the Overpass API but I just can'T find the right parameters to list all cities (and not just the top 1000 or so).

Does anyone know a way to do this that returns proper JSON?

like image 791
Tobias Timpe Avatar asked May 06 '14 17:05

Tobias Timpe


1 Answers

Your query isn't (IMHO) a good one for an API, as your results are very sparse but need to run over all the data (no general indexing).

So get an OSM extact, filter it with osmosis and then do your own processing on the results.

Keep in mind, that a town can be modelled differently in OSM:

  • as tagged node e.g. place=city
  • as landuse area (also with additional place tags)
  • as boundary so, a (multipolygon)relation

You might also want to have a look at nominatim for geocoding and the legal FAQ for distributing OSM data.

like image 145
MaM Avatar answered Oct 13 '22 10:10

MaM