graph_from_place OSMNX 的响应时间极长

Extremely long response time with graph_from_place OSMNX

我正在尝试下载墨西哥地图以避免使用 save_graphml 查询并避免 graph_from_place 中的长时间响应,但我已经留下了此代码 运行宁近六个小时,完全没有任何反应。

import osmnx as ox

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

G = ox.graph_from_place('Mexico', network_type = 'drive', simplify=False)
G = ox.add_edge_speeds(G)
G = ox.add_edge_travel_times(G)

ox.save_graphml(G, '/var/www/html/repmexico.graphml')

print("Success!!!")

今天我正在尝试 运行 具有 74GB RAM 和 (Intel xeon x5570) X2

的服务器上的代码

(我知道由于规定的区域时间很长,但我想知道是否有替代此过程的方法或者是否有优化的方法以便创建地图快一点或者如果有另一种方法可以加载地图以使用 osmnx 和 networkx 路由而不使用对服务器的查询)

I've already left this code running for almost six hours and absolutely nothing happens.

发生了很多事情!不相信我?你 运行 ox.config(log_console=True),所以看看你的终端,看看它运行时发生了什么。您会看到一行类似“2021-10-14 13:05:39 在 1827 次请求中从 API 请求多边形内的数据”...所以您向 Overpass 服务器发出了 1,827 个请求,并且服务器要求您暂停以限制其中许多请求之间的速率。

I know that due to the stipulated area the time is long, but what I wanted to know is if there is an alternative to this procedure or if there is a way to optimize so that the creation of the map is a little faster or if there is another way to load maps to route with osmnx and networkx without using queries to servers

是的。这个 provides more details. There are tradeoffs between 1) model precision vs 2) area size vs 3) memory/speed. For faster modeling, you can load the network data from a .osm XML file instead of having to make numerous calls to the Overpass API. I'd also recommend using a custom_filter as described in the linked answer. OSMnx by default divides your query area into 50km x 50km pieces, then queries Overpass for each piece one a time to not exceed the server's per-query memory limits. You can configure 这个 max_query_area_size 参数,以及服务器内存分配,如果你更喜欢使用 OSMnx 的 API 查询函数而不是它的来自文件的功能。