我有一个带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" }
有没有比使用Google的地理编码API的边界框更好的方法?
这个答案提供了来自TIGER数据的多边形城市边界的链接(仅限美国):https://stackoverflow.com/a/10821465/3146587.格式为shapefile,但您可以使用ogr2ogr
例如将其轻松转换为GeoJSON .
这引起了我的注意:所有城市,州,地球上的国家都在一个大的geojson文件中:https://mapzen.com/data/borders/