如何从地理数据中获取城市
Posted
技术标签:
【中文标题】如何从地理数据中获取城市【英文标题】:How to get Cities from Geo Data 【发布时间】:2019-08-07 08:01:03 【问题描述】:我有一些关于汽车(尤其是运输卡车)的数据。数据包括车辆的时间、纬度和经度等。
示例如下:
Latitude Longitude UTC
19.250463 73.042856 2018-12-01 00:02:19
19.249853 73.043862 2018-12-01 00:04:12
19.24953 73.043923 2018-12-01 00:04:41
19.249527 73.043938 2018-12-01 00:09:12
19.249457 73.044172 2018-12-01 00:14:12
19.249484 73.044128 2018-12-01 00:19:12
有很多数据。我现在面临的问题是找到这辆特定车辆访问的各个“城市”。
这是一张经纬度图:
这里我将每个点20KM半径内的点数作为特征添加到数据中。然后我在这三个特征上应用了 DBSCAN 并将类表示为颜色。
如您所见,它无法识别“交点”点。理想情况下,我需要一种方法来查找此数据中的角点和端点。
预定义城市列表及其位置不是一种选择,因为这些卡车的一般情况可能会有很大差异,然后也可以访问小城镇。
【问题讨论】:
【参考方案1】:有几种方法可以解决这个问题。第一个可能是性能最高的,它是使用此处提供的信息自己构建逆地理编码数据库:http://download.geonames.org/export/dump/
当然,这些信息必须保持最新,这可能会很麻烦。
如果您可以接受一点延迟,也有第三方服务可以为您执行此操作。我运行这些第三方服务之一,称为https://geo-info.co/
您可以使用此 API 轻松解决此问题。例如
https://geo-info.co/19.250463,73.042856
这将返回城市以及其他一些信息,例如附近的位置。
"city": "Vishnunagar",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.267",
"longitude": "73.0715",
"nearby": [
"city": "Dombivali I.A.",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.267",
"longitude": "73.0715",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421203"
,
"city": "Dombivali",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
,
"city": "Ramnagar (Thane)",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
,
"city": "Thakurli",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
,
"city": "Tilaknagar (Thane)",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.2167",
"longitude": "73.0833",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421201"
,
"city": "Bhiwandi",
"community": "Bhiwandi",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3002",
"longitude": "73.0588",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421308"
,
"city": "Khoni",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
,
"city": "Manpada",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
,
"city": "Nilje",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
,
"city": "Padle",
"community": "Kalyan",
"community2": "",
"country": "IN",
"county": "Thane",
"county2": "517",
"latitude": "19.3173",
"longitude": "73.0597",
"state": "Maharashtra",
"state2": "16",
"zipcode": "421204"
],
"state": "Maharashtra",
"state2": "16",
"zipcode": "421202"
【讨论】:
谢谢!附近的功能似乎对我特别有用。虽然我想知道是否有任何方法分析这个并获得该图中的端点? 您能否再解释一下该图中的端点是什么意思?我不认为我在关注。以上是关于如何从地理数据中获取城市的主要内容,如果未能解决你的问题,请参考以下文章
如何将从地理位置获得的城市与我的数据库中存储的城市进行比较,如果城市存在,则通过 ajax 请求传递 id?