python - 将一个点捕捉到自定义道路网络
问题描述
这不是一个重复的问题,因为我有一些具体要求。请提供输入 wrt python。我有一个节点坐标形式的道路网络,即我拥有城市所有路线的所有纬度和经度。
现在,我有一个 GPS 坐标列表(公交路线),我想将其与原始路线相匹配。
这类似于 Google 道路 API。我尝试使用反向地理编码器,但我能理解它..请帮助
解决方案
你可以使用 python 的osmnx包。您可以创建纬度和经度坐标的边界框,检索此框的适当地图数据,然后将经纬度坐标捕捉到街道网络的最近节点。
bounding_box = ((gps_df.longitude.min(), gps_df.longitude.max(),
gps_df.latitude.min(), gps_df.latitude.max()))
# Downloading the map as a graph object
g = ox.graph_from_bbox(north, south, east, west, network_type='drive')
route = []
# get the nearest nodes to the locations
for i in range(len(lat_list)):
node = ox.get_nearest_node(g, (lat_list[i], long_list[i]))
route.append(node)
#flat the lists
edge_nodes = list(zip(route[:-1], route[1:]))
推荐阅读
- c# - 具有通用类型约束的工厂模式
- c# - C# WPF 更改 DatePicker 内的 BorderBrush
- javascript - 不要向错误的原型添加方法
- django - 将查询集的参数传递给 Django 表单
- typescript - Jest spyOn 不使用打字稿:“'Spy' 类型中缺少属性 'mockRestore'”
- python - 使用 MongoEngine 保存和更新嵌套文档
- javascript - 我的 Rails 应用程序中的 Coffeescript 组织:一些 js 没有触发
- wordpress - 强制 Facebook 共享调试器元 - Wordpress 清除缓存
- c++ - 我是否需要手动将 PCREDENTIAL.CredentialBlob 归零?
- typescript - jhipster:在角度客户端上不支持过滤实体的 jhipster 生成?