第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

OSMNX 最短路徑節(jié)點 - 獲取節(jié)點行進時間

OSMNX 最短路徑節(jié)點 - 獲取節(jié)點行進時間

Go
動漫人物 2022-12-20 11:14:43
我想使用 Osmnx 獲取最短路徑路線中節(jié)點之間的旅行時間。有沒有辦法獲得節(jié)點之間的旅行時間。import networkx as nximport osmnx as oxox.config(use_cache=True, log_console=True)import pandas as pdpla__version__Piedmont, CA, USAG = ox.graph_from_place(place, network_type='drive')orig = list(G)[0]dest = list(G)[-1]route = nx.shortest_path(G, orig, dest)#fig, ax = ox.plot_graph_route(G, route, route_linewidth=6, node_size=0, bgcolor='k')for i, val in enumerate(route):    print(i, val, G.nodes[val]['x'], G.nodes[val]['y'])我想存儲節(jié)點,在上面的循環(huán)中實現(xiàn)的緯度和經(jīng)度,但是有沒有辦法存儲兩個節(jié)點之間的旅行時間和/或兩個節(jié)點之間的距離。
查看完整描述

1 回答

?
MYYA

TA貢獻1868條經(jīng)驗 獲得超4個贊

OSM 關(guān)于速度和旅行時間的數(shù)據(jù)往往參差不齊。使用 OSMnx 的速度模塊估算缺失的邊緣速度并計算自由流動的行駛時間。


import networkx as nx

import osmnx as ox

import pandas as pd

ox.config(use_cache=True, log_console=True)


place = 'Piedmont, CA, USA'

G = ox.graph_from_place(place, network_type='drive')


# impute missing edge speeds and add travel times

G = ox.add_edge_speeds(G)

G = ox.add_edge_travel_times(G)


# calculate route minimizing some weight

orig, dest = list(G)[0], list(G)[-1]

route = nx.shortest_path(G, orig, dest, weight='travel_time')


# OPTION 1: see the travel time for the whole route

travel_time = nx.shortest_path_length(G, orig, dest, weight='travel_time')

print(round(travel_time))


# OPTION 2: loop through the edges in your route

# and print the length and travel time of each edge

for u, v in zip(route[:-1], route[1:]):

    length = round(G.edges[(u, v, 0)]['length'])

    travel_time = round(G.edges[(u, v, 0)]['travel_time'])

    print(u, v, length, travel_time, sep='\t')


# OPTION 3: use get_route_edge_attributes

cols = ['osmid', 'length', 'travel_time']

attrs = ox.utils_graph.get_route_edge_attributes(G, route)

print(pd.DataFrame(attrs)[cols])


查看完整回答
反對 回復(fù) 2022-12-20
  • 1 回答
  • 0 關(guān)注
  • 199 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號