OSMnx:如何在 custom_filter 参数中提供更复杂的功能
OSMnx : how to provide more complex feature into the custom_filter parameter
我想将一些天桥请求传递给 ox.graph_from_place
,但我真的不明白它如何与文档一起工作。
我想创建一个包含 2 种道路的图表(公共汽车可以通过的地方和 psv 也可以通过的地方)
我必须加入我的 2 个图表吗?或者有没有更直接的方法?
G1 = ox.graph_from_place('Marseille, France', retain_all=True, custom_filter='["bus"="yes"]')
G2 = ox.graph_from_place('Marseille, France', retain_all=True, custom_filter='["psv"="yes"]')
Gtot = nx.disjoint_union(G1,G2)
有人知道答案吗?
祝你有美好的一天
由于 OSMnx 在其查询设备中不包含针对多个键的可自定义联合运算符,因此最好的办法确实是进行两个查询,然后将它们组合起来。但是你应该使用 compose
函数来这样做:
import networkx as nx
import osmnx as ox
ox.config(use_cache=True, log_console=True)
place = 'Marseille, France'
G1 = ox.graph_from_place(place, network_type='drive', retain_all=True, custom_filter='["bus"="yes"]')
G2 = ox.graph_from_place(place, network_type='drive', retain_all=True, custom_filter='["psv"="yes"]')
G = nx.compose(G1, G2)
print(len(G1), len(G2), len(G)) #784 141 855
另见 and
我想将一些天桥请求传递给 ox.graph_from_place
,但我真的不明白它如何与文档一起工作。
我想创建一个包含 2 种道路的图表(公共汽车可以通过的地方和 psv 也可以通过的地方)
我必须加入我的 2 个图表吗?或者有没有更直接的方法?
G1 = ox.graph_from_place('Marseille, France', retain_all=True, custom_filter='["bus"="yes"]')
G2 = ox.graph_from_place('Marseille, France', retain_all=True, custom_filter='["psv"="yes"]')
Gtot = nx.disjoint_union(G1,G2)
有人知道答案吗?
祝你有美好的一天
由于 OSMnx 在其查询设备中不包含针对多个键的可自定义联合运算符,因此最好的办法确实是进行两个查询,然后将它们组合起来。但是你应该使用 compose
函数来这样做:
import networkx as nx
import osmnx as ox
ox.config(use_cache=True, log_console=True)
place = 'Marseille, France'
G1 = ox.graph_from_place(place, network_type='drive', retain_all=True, custom_filter='["bus"="yes"]')
G2 = ox.graph_from_place(place, network_type='drive', retain_all=True, custom_filter='["psv"="yes"]')
G = nx.compose(G1, G2)
print(len(G1), len(G2), len(G)) #784 141 855
另见 and