城市Geojson多边形数据库/库或API

Dio*_*lor 4 google-maps geocoding polygons geojson google-maps-api-3

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

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

在此输入图像描述

我看到了Maxmind的数据库,但每个城市没有边界.

到目前为止,我最好的解决方案是使用Google的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"
}
Run Code Online (Sandbox Code Playgroud)

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

小智 6

这引起了我的注意:所有城市,州,地球上的国家都在一个大的geojson文件中:https://mapzen.com/data/borders/

  • 服务已关闭。有人对巨型文件有镜子吗? (2认同)
  • 有人在某处有此文件的副本吗? (2认同)

use*_*587 5

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

  • 但是我需要全球解决方案而不仅仅是美国. (2认同)
  • [GADM](http://gadm.org/)是一个管理边界的全局数据集(shapefile格式可用),_should_包含城市边界.另外我还发现这个(相当复杂的)尝试通过他们的Overpass API从OSM中提取城市边界:https://github.com/pgkelley4/city-boundaries-google-maps (2认同)