【问题标题】:Cities Geojson polygons database/library or API城市 Geojson 多边形数据库/库或 API
【发布时间】:2014-01-15 08:17:56
【问题描述】:

我有一个带有 lat/long 标记的 MongoDB 数据库,我需要另一个包含城市或区域级别边界的数据库(或其他解决方案)。如果在 Geojson 多边形中它会是最佳的。

我有一个名为 city 的字段(例如 'city' : 'New York'),但我想缩小到城市的区域/社区级别,例如“苏荷”。以这种方式解决问题的想法是基于谷歌的新地图。如果我们输入区域或邮政编码,我们会看到该区域的红点多边形。

我看到了Maxmind's 数据库,但它没有每个城市的边界。

到目前为止,我最好的解决方案是使用Google's Geocoding API,它返回一个框的边界:

例如对于:http://maps.googleapis.com/maps/api/geocode/json?address=soho&sensor=false

结果:

{
   "results" : [
      {
         "address_components" : [
            {
               "long_name" : "SoHo",
               "short_name" : "SoHo",
               "types" : [ "neighborhood", "political" ]
            },
            {
               "long_name" : "Manhattan",
               "short_name" : "Manhattan",
               "types" : [ "sublocality", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "New York",
               "types" : [ "locality", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "New York",
               "types" : [ "administrative_area_level_2", "political" ]
            },
            {
               "long_name" : "New York",
               "short_name" : "NY",
               "types" : [ "administrative_area_level_1", "political" ]
            },
            {
               "long_name" : "United States",
               "short_name" : "US",
               "types" : [ "country", "political" ]
            }
         ],
         "formatted_address" : "SoHo, New York, NY, USA",
         "geometry" : {
            "bounds" : {
               "northeast" : {
                  "lat" : 40.7283442,
                  "lng" : -73.9953929
               },
               "southwest" : {
                  "lat" : 40.7184446,
                  "lng" : -74.0054619
               }
            },
            "location" : {
               "lat" : 40.723384,
               "lng" : -74.001704
            },
            "location_type" : "APPROXIMATE",
            "viewport" : {
               "northeast" : {
                  "lat" : 40.7283442,
                  "lng" : -73.9953929
               },
               "southwest" : {
                  "lat" : 40.7184446,
                  "lng" : -74.0054619
               }
            }
         },
         "types" : [ "neighborhood", "political" ]
      }
   ],
   "status" : "OK"
}

有比使用 Google 的地理编码 API 的边界框更好的方法吗?

【问题讨论】:

  • 您找到解决方案了吗?我正在寻找此信息的来源。如果 google api 有它,那将非常有帮助。

标签: google-maps google-maps-api-3 geocoding geojson polygons


【解决方案1】:

这让我大吃一惊:地球上的所有城市、州、国家都在一个大的 geojson 文件中: https://mapzen.com/data/borders/

【讨论】:

  • Mapzen 将于 2018 年 2 月 1 日关闭其服务,此文件托管在其 S3 帐户上,这意味着此下载也可能在未来不复存在。最好尽可能地抓住它:)
  • 服务已关闭。有人有巨型文件的镜像吗?
  • 有人有这个文件的副本吗?
【解决方案2】:

此答案提供了 TIGER 数据中多边形城市边界的链接(仅限美国):https://stackoverflow.com/a/10821465/3146587。格式是 shapefile,但您可以使用 ogr2ogr 轻松将其转换为 GeoJSON。

【讨论】:

  • 赞成,但我需要一个全球解决方案,而不仅仅是美国。
  • GADM 是行政边界的全球数据集(shapefile 格式等可用),应该包括城市边界。否则我还发现这个(相当参与)试图通过他们的 Overpass API 从 OSM 中提取城市边界:github.com/pgkelley4/city-boundaries-google-maps
猜你喜欢
  • 2017-10-25
  • 2016-12-13
  • 1970-01-01
  • 1970-01-01
  • 2011-03-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多