2

我花了一个下午的时间寻找世界上最重要的城市的开放数据库,

它们中的大多数都是高级的,价格大约是 400 美元,但是由于我正在从事一个开源项目,我想使用开放数据,有什么地方可以下载重要城市的名称吗?

我找到了开放的街道地图,但它是 16gb 的东西,例如节点关系,但我只需要城市名称和坐标,

非常感谢你,

G

4

1 回答 1

16

这可能比您想要的更多,但您可以使用 Overpass API 来查询所有具有["place"="city"].

例如,访问http://www.overpass-api.de/query_form.html并输入以下内容:

node
  ["place"="city"];
out body;

用于 XML 输出,或以下用于 JSON:

[out:json];
node
  ["place"="city"];
out body;

输出需要一分钟左右才能返回给我(它返回了 5,000 多个节点),但如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<osm version="0.6" generator="Overpass API">
<note>The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history </note>
<meta osm_base="2012-07-22T13:38:02Z"/>

  <node id="107775" lat="51.5072759" lon="-0.1276597">
    <tag k="capital" v="yes"/>
    <tag k="is_in" v="England, United Kingdom, UK, Great Britain, Europe"/>
    <tag k="is_in:continent" v="Europe"/>
    <tag k="is_in:country" v="United Kingdom"/>
    <tag k="name" v="London"/>
    <tag k="name:ast" v="Londres"/>
    <tag k="name:be" v="Лондан"/>
    <tag k="name:br" v="Londrez"/>
    <tag k="name:cs" v="Londýn"/>
    <tag k="name:cy" v="Llundain"/>
    <tag k="name:de" v="London"/>
    <tag k="name:el" v="Λονδίνο"/>
    <tag k="name:en" v="London"/>
    <tag k="name:eo" v="Londono"/>
    <tag k="name:es" v="Londres"/>
    <tag k="name:fa" v="لندن"/>
    <tag k="name:fi" v="Lontoo"/>
    <tag k="name:fr" v="Londres"/>
    <tag k="name:ga" v="Londain"/>
    <tag k="name:gd" v="Lunnainn"/>
    <tag k="name:gv" v="Lunnin"/>
    <tag k="name:he" v="לונדון"/>
    <tag k="name:is" v="Lundúnir"/>
    <tag k="name:it" v="Londra"/>
    <tag k="name:ja" v="ロンドン"/>
    <tag k="name:ku" v="London"/>
    <tag k="name:la" v="Londinium"/>
    <tag k="name:lv" v="Londona"/>
    <tag k="name:nl" v="Londen"/>
    <tag k="name:pl" v="Londyn"/>
    <tag k="name:pt" v="Londres"/>
    <tag k="name:ru" v="Лондон"/>
    <tag k="name:sk" v="Londýn"/>
    <tag k="name:sr" v="Лондон"/>
    <tag k="name:sv" v="London"/>
    <tag k="name:uk" v="Лондон"/>
    <tag k="name:vi" v="Luân Äôn"/>
    <tag k="name:zh" v="伦敦"/>
    <tag k="name:zh_pinyin" v="Lúndūn"/>
    <tag k="note" v="Centre of London classed as on the charles I moment near trafalgar square"/>
    <tag k="place" v="city"/>
    <tag k="population" v="7556900"/>
    <tag k="rank" v="0"/>
    <tag k="wikipedia" v="http://en.wikipedia.org/wiki/London"/>
    <tag k="wikipedia:en" v="London"/>
    <tag k="wikipedia:fr" v="Londres"/>
  </node>

或 JSON 的以下内容:

{
  "version": 0.6,
  "generator": "Overpass API",
  "osm3s": {
    "timestamp_osm_base": "2012-07-22T14:02:02Z",
    "copyright": "The data included in this document is from www.openstreetmap.org. It has there been collected by a large group of contributors. For individual attribution of each item please refer to http://www.openstreetmap.org/api/0.6/[node|way|relation]/#id/history"
  },
  "elements": [

{
  "type": "node",
  "id": 107775,
  "lat": 51.5072759,
  "lon": -0.1276597,
  "tags": {
    "capital": "yes",
    "is_in": "England, United Kingdom, UK, Great Britain, Europe",
    "is_in:continent": "Europe",
    "is_in:country": "United Kingdom",
    "name": "London",
    "name:ast": "Londres",
    "name:be": "Лондан",
    "name:br": "Londrez",
    "name:cs": "Londýn",
    "name:cy": "Llundain",
    "name:de": "London",
    "name:el": "Λονδίνο",
    "name:en": "London",
    "name:eo": "Londono",
    "name:es": "Londres",
    "name:fa": "لندن",
    "name:fi": "Lontoo",
    "name:fr": "Londres",
    "name:ga": "Londain",
    "name:gd": "Lunnainn",
    "name:gv": "Lunnin",
    "name:he": "×œ×•× ×“×•×Ÿ",
    "name:is": "Lundúnir",
    "name:it": "Londra",
    "name:ja": "ロンドン",
    "name:ku": "London",
    "name:la": "Londinium",
    "name:lv": "Londona",
    "name:nl": "Londen",
    "name:pl": "Londyn",
    "name:pt": "Londres",
    "name:ru": "Лондон",
    "name:sk": "Londýn",
    "name:sr": "Лондон",
    "name:sv": "London",
    "name:uk": "Лондон",
    "name:vi": "Luân Äôn",
    "name:zh": "伦敦",
    "name:zh_pinyin": "Lúndūn",
    "note": "Centre of London classed as on the charles I moment near trafalgar square",
    "place": "city",
    "population": "7556900",
    "rank": "0",
    "wikipedia": "http://en.wikipedia.org/wiki/London",
    "wikipedia:en": "London",
    "wikipedia:fr": "Londres"
  }
},

更多信息:

于 2012-07-22T14:08:09.827 回答