如何在osmnx中导入多种基础架构类型? [英] How to import multiple infrastructure type in osmnx?

查看:100
本文介绍了如何在osmnx中导入多种基础架构类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用osmnx导入道路时,是否有任何方法可以为基础结构类型指定多个子类别.来自这个问题,我知道我们只能通过指定infrastructure='way["highway"~"motorway"]'来选择高速公路.我们如何扩展它以包括多个类别,例如highways = motorway or primary or secondaryhighway is not footway

Is there any way to specify multiple subcategories for an infrastructure type while importing roads using osmnx. From this question I understand that we can select only freeways by specifying infrastructure='way["highway"~"motorway"]'. How can we expand this to include multiple categories such as highways = motorway or primary or secondary or highway is not footway

我尝试了以下操作但未成功:

I tried the following without success:

infrastructure='way["highway"~"motorway"],way["highway"~"primary"]'
infrastructure='way["highway"~"motorway", "primary"]'
infrastructure='way["highway"~"motorway" OR "primary"]'

最好具有更好的过滤功能,例如highway=primary or highway=primary_link(示例这里的键)

It would be nice to have better filtering such as highway=primary or highway=primary_link (examples here , keys here)

推荐答案

使用管道|作为立交or运算符,例如:

Use the pipe | as an overpass or operator like:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
place = 'Berkeley, California, USA'

cf = '["highway"~"motorway|motorway_link"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #36

cf = '["highway"~"primary"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #11

cf = '["highway"~"motorway|motorway_link|primary"]'
G = ox.graph_from_place(place, network_type='drive', custom_filter=cf)
print(len(G)) #47

这篇关于如何在osmnx中导入多种基础架构类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆