7

I have tried to retrieve them from the api with the following:

wget -O allcities.xml "http://www.overpass-api.de/api/xapi_meta?node[admin_level=8]"

however it does not seem to return all of them. From the doc Admin Level 8 should be cities, towns and villages but it seems to only contain major cities. I get a list of about 12000 nodes.

I am actually looking into getting all inhabited places on earth with at least 1000 population.

I am also downloading the whole planet in PBF format, in case using the API is not possible. How would I be able to achieve the same using such file?

  • 2
    Please ask only one question per Question. – Vince Mar 20 '16 at 16:11
  • I clearly asked only one question and it is in the title. – Simone Zandara Mar 20 '16 at 21:10
  • 1
    Your second question was how to extract the information from PBF. Two question marks, two questions. – Vince Mar 20 '16 at 21:26
  • It's a close call but I think it is currently two questions too i.e. How to get expected result from API? How to get expected result from download? – PolyGeo Mar 20 '16 at 21:45
  • Sorry I have to disagree you here. I am not interested specifically in the PBF or API way, those are just two approaches I have been trying with. I would be open to any other suggestions. – Simone Zandara Mar 21 '16 at 9:12
5

I ended up using osmosis with the following call.

./osmosis --read-pbf planet-latest.osm.pbf --tf accept-nodes place=city,town,village --tf reject-relations --tf reject-ways --lp --write-pgsql database=postgis_test user=*** password=***

This seems to contain all cities that I was looking for. Cannot still say much on the data itself. After a couple of test it seems to contain a good amount of places even small villages.

In order to do that I had to however download the full OSM data of about 31 GB.

| improve this answer | |
  • ... next to Osmosis, you can also try OSMFilter ... see wiki.openstreetmap.org/wiki/Osmfilter ... some users say it is a bit faster. – stephan75 Mar 21 '16 at 19:43
  • 1
    Thanks for the tip, it seems to do more or less the same. Honestly I am getting confused with so many OSM tools :) – Simone Zandara Mar 22 '16 at 16:04
  • Instead of outputting one file containing all the nodes, can I spit out 1 file per node or city ? thx. – user117775 Apr 2 '18 at 13:54
3

I haven't used the service, but gisgraphy.com - lists 4.3 million cities available via extract from OSM.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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