OSMnx没有“速度”属性

2024-04-18 23:45:14 发布

您现在位置:Python中文网/ 问答频道 /正文

我已成功下载了osmnx的0.14.0版本:

enter image description here

但是输出显示AttributeError:module'osmnx'没有属性'speed'。enter image description here

我能做些什么来解决这个问题? 我的python版本是3.8.1

此外,以下是代码:

import folium
import pandas as pd 
import numpy as np  
import osmnx as ox
import networkx as nx
import os

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

G = ox.graph_from_point((-33.889606, 151.283306), distance=3000, network_type='drive')

G = ox.speed.add_edge_speeds(G)
G = ox.speed.add_edge_travel_times(G)

orig = ox.get_nearest_node(G, (-33.889606, 151.283306))
dest = ox.get_nearest_node(G, (-33.862004, 151.211151))
route = nx.shortest_path(G, orig, dest, 'travel_time')

route_map = ox.plot_route_folium(G, route)
route_map.save('route_333.html')

Tags: import版本addtruegetasrouteox
1条回答
网友
1楼 · 发布于 2024-04-18 23:45:14

更新OSMnx

  • 使用pip:pip install -U osmnx
  • 使用conda:conda update osmnx

然后编辑此行:

G = ox.graph_from_point((-33.889606, 151.283306), distance=3000, network_type='drive')

进入:

G = ox.graph_from_point((-33.889606, 151.283306), dist=3000, network_type='drive')

你可以得到你的地图:

enter image description here

相关问题 更多 >