Reputation: 770
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?
Upvotes: 8
Views: 16675
Reputation: 11119
Using Overpass API.
area["ISO3166-1"="CY"]->.a1;
(
nwr[place="city"](area.a1);
);
out body;
Link. Open console and click run to see the request and response.
Or use curl
curl 'https://lz4.overpass-api.de/api/interpreter' \
--data-raw 'data=[out:json];area["ISO3166-1"="CY"]->.a1;
(
nwr[place="city"](area.a1);
);
out body;'
Upvotes: 1
Reputation: 171
Try Overpass_API
For example, all states of Germany:
http://overpass-api.de/api/interpreter?data=(rel[admin_level="4"](47,6,55,15););out;
Upvotes: 0
Reputation: 2069
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:
You might also want to have a look at nominatim for geocoding and the legal FAQ for distributing OSM data.
Upvotes: 7