【问题标题】:Osmnx: How to retreive info on bus-stop info node, which is part of a highway?Osmnx:如何检索公共汽车站信息节点上的信息,它是高速公路的一部分?
【发布时间】:2019-09-12 14:59:05
【问题描述】:

我正在尝试显示 OpenStreetMap 公交车站节点 439460636 (https://www.openstreetmap.org/node/439460636) 的信息,该节点是高速公路的一部分。

我正在使用 Python3 Osmnx

其他 POI 均显示完美。只是不是那些没有被映射为“便利设施”的人。 (还有更多例子)

我正在使用 jupyter notebook 进行分析:

import osmnx as ox

# Retrieve POI shelters
place_name = 'Santa Clara, Santa Clara County, California, USA'
shelter = ox.pois_from_place(place_name, amenities=['shelter'])
cols = ['amenity', 'name', 'element_type', 'shelter_type',
       'building', 'network'
        ]
shelter[cols]
cols = ['amenity', 'name','element_type', 'shelter_type',
       'building', 'network'
        ]
shelter[cols].loc[(shelter['shelter_type'] == 'public_transport') ]
# Look bus-stop in highway
graph = ox.graph_from_place(place_name)
nodes, edges = ox.graph_to_gdfs(graph)
nodes.loc[(nodes['highway'] == 'bus_stop') ]

立交桥:

[out:json][timeout:25];
// gather results
(
  area[name="Santa Clara, Santa Clara County, California, USA"];
  node(area)["highway"="bus_stop"]({{bbox}});
);
// print results
out body;
>;
out skel qt;

POI Kino (439460636) 未列出。列出了 POI 旁边的避难所。 POI 在我所在区域的中间,所以我不明白如何检索节点信息。你能帮忙吗?

【问题讨论】:

  • node 439460636不是高速公路的一部分,它只有一个highway=bus_stop 标签。这只是一个tag,与element type 没有太大关系。我猜graph_from_place() 不包括公交车站,因为它们并不是道路网络的一部分。您可能需要调用不同的函数,但不幸的是我不熟悉 osmnx。
  • pois_from_place() 只寻找便利设施而不接受其他键的事实对我来说似乎是一个设计错误。 POI 可以有各种标签,而不仅仅是amenity。或许您可以使用overpass_request() 下载兴趣点。
  • 这个 Overpass 查询找到节点...:[out:json][timeout:25]; // 收集结果 ( node["highway"="bus_stop"]({{bbox}}); ); // 打印结果 body; >;出 skel qt;
  • 这是 Osmnx 中的一个“功能”。在 11 月,chesterharvey 创建了一个更新,这似乎还不是标准的一部分。手动替换文件,它现在可以工作了。 github.com/gboeing/osmnx/issues/116#issuecomment-439577495
  • 太棒了!我想您可以将其发布为您问题的答案。

标签: python openstreetmap osmnx


【解决方案1】:

使用 Chesterharvey 这篇文章中链接的文件手动更新 Osmnx。 https://github.com/gboeing/osmnx/issues/116#issuecomment-439577495 功能的最终测试仍未完成!

import osmnx as ox

# Specify the name that is used to seach for the data
place_name = "Santa Clara, Santa Clara County, California, USA"

tags = {
    'amenity':True,
    'leisure':True,
    'landuse':['retail','commercial'],
    'highway':'bus_stop',
}

all_pois = ox.pois_from_place(place=place_name, tags=tags)
all_pois.loc[(all_pois['highway'] == 'bus_stop')]

【讨论】:

  • github.com/gboeing/osmnx/pull/449 OSMnx 的主分支中添加了泛化 pois 模块以与所有兴趣点一起工作的功能,它将在下一个版本中出现。
【解决方案2】:

从 v0.13.0 开始,此功能作为 been added 到 OSMnx。它将 POI 模块概括为使用 tags 字典而不是 amenities 列表进行查询。它从所有 POI 函数中删除 amenities 参数。 tags dict 接受以下形式的键:值对:

  1. 'tag' : True(使用 bool 检索所有带有 tag 的项目)
  2. 'tag' : 'value'(使用字符串检索所有带有tag = value 的项目)
  3. 'tag' : ['value1', 'value2', etc](使用列表检索所有tag 等于value1value2 等的项目。

新增兴趣点查询功能使用示例:

import osmnx as ox
ox.config(use_cache=True, log_console=True)
tags = {'amenity' : True,
        'landuse' : ['retail', 'commercial'],
        'highway' : 'bus_stop'}
gdf = ox.pois_from_place(place='Piedmont, California, USA', tags=tags)

【讨论】:

    【解决方案3】:

    我认为你可以用脚印轻松做到这一点:

    #point of interests around an aread
    import networkx as nx
    import osmnx as ox
    import requests
    
    #returns polygon or coordinates of poi
    #point = (59.912390, 10.750584)
    #amn = ["bus_station",'waste_transfer_station'] #["bus_station",'waste_transfer_station']
    #points of interest/amenities we can use: https://wiki.openstreetmap.org/wiki/Key:amenity
    def get_interest_points(long,lat,dist,amn[]):
        point = (long, lat)
        gdf_points = ox.pois_from_point(point, distance=dist, amenities=amn)
        return gdf_points[["amenity", "geometry"]]
    
    #Get bus buildings, distance in meter 400 is minimum
    #returns polygon of building
    def get_buildings(long,lat,dist):
        point = (long, lat)
        gdf = ox.footprints.footprints_from_point(point=point, distance=dist,footprint_type='buildings')
        return gdf["geometry"]
    
    #Get bus, tram or subway
    #type = "bus" or "tram" or "subway"
    #, distance in meter 400 is minimum
    #returns polygon of stop
    def get_buildings(long,lat,dist,type):
        point = (long, lat)
        gdf = ox.footprints.footprints_from_point(point=point, distance=dist,footprint_type=type)
        return gdf["geometry"]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-03
      • 1970-01-01
      相关资源
      最近更新 更多