10

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?

birkett
  • 287
  • 1
  • 2
  • 7
  • 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. – birkett 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. – birkett Mar 21 '16 at 09:12

2 Answers2

7

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.

birkett
  • 287
  • 1
  • 2
  • 7
  • ... next to Osmosis, you can also try OSMFilter ... see http://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 :) – birkett 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. –  Apr 02 '18 at 13:54
2

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

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
dghedini
  • 51
  • 6