9

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?

5
  • 2
    Please ask only one question per Question.
    – Vince
    Mar 20, 2016 at 16:11
  • I clearly asked only one question and it is in the title. Mar 20, 2016 at 21:10
  • 1
    Your second question was how to extract the information from PBF. Two question marks, two questions.
    – Vince
    Mar 20, 2016 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, 2016 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. Mar 21, 2016 at 9:12

2 Answers 2

6

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.

3
  • ... 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, 2016 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 :) Mar 22, 2016 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, 2018 at 13:54
2

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

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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