我有一个带lat / long标记的MongoDB数据库,我需要另一个包含城市或区域级边界的数据库(或其他解决方案)。如果在Geojson多边形中,它将是最佳的。
我有一个名为city的字段(例如'city' : 'New York'
)但我希望缩小到某个城市的区域/邻域级别,例如“苏荷”。以这种方式解决问题的想法是基于谷歌的新地图。如果我们输入区域或邮政编码,我们会看到该区域的红点多边形。
我看到了Maxmind's数据库,但每个城市没有边界。
到目前为止,我最好的解决方案是使用Google's Geocoding API返回一个框的边界:
e.g。 for: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的边界框更好的方法吗?
答案 0 :(得分:6)
这引起了我的注意:所有城市,州,地球的国家都在一个大的geojson文件中: https://github.com/kraih/mojo/issues/733
答案 1 :(得分:5)
此答案提供了来自TIGER数据的多边形城市边界的链接(仅限美国):https://stackoverflow.com/a/10821465/3146587。格式为shapefile,但您可以使用ogr2ogr
轻松将其转换为GeoJSON。