開放街圖標誌 OpenStreetMap 開放街圖

Generating a list of all the cities in the world with Wikipedia links

於 2017年三月 8日 由 PlaneMadEnglish發表。 上一次更新在 2017年三月 9日。

A small tutorial on how one can export a CSV of all the cities in the world with their associated Wikipedia and Wikidata pages. This is useful if you want to do some spreadsheet analysis of data from OpenStreetMap.

Overpass Turbo is a great way to quickly extract data from OpenStreetMap by querying tags. An easy way to generate the query is to type “city” or the specific tag “place=city” in the wizard. Since most cities are tagged as just a point node, we can remove the query for ways and relations.

Also instead of the default geojson output, you can use the CSV output format and specify the the data columns to export. The end query looks like this:

[out:csv(::type,::id,name,”name:en”,wikipedia,wikidata)][timeout:200];

( node[“place”=”city”] ({{bbox}}); );

Try the live query (takes around 2 minutes to run) View results

The same query with a geojson output gives the map view

You might also be interested in reading about how one can query a similar list from Wikidata.

電子郵件圖示 藍天圖示 Facebook 圖示 LinkedIn 圖示 乳齒象圖示 Telegram 圖示 X 圖示

討論

dieterdreist2017年03月15日 15時35分 發表的評論

You’d better change the live example with something less ressource consuming, if it’s for demonstration purposes only. Why do you think it takes 2 minutes?

登入 來留下評論