Osmnx:如何在高速公路的公交车站信息节点上检索信息?

时间:2019-04-23 12:11:59

标签: python openstreetmap osmnx

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

我正在使用Python3 Osmnx

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

我正在使用jupyter笔记本进行分析:

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位于我区域的中间,所以我不明白如何获取节点信息。你能帮忙吗?

3 个答案:

答案 0 :(得分:2)

使用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')]

答案 1 :(得分:1)

此功能自v0.13.0起为OSMnx的been added。它将POIs模块推广为使用tags字典而不是amenities列表进行查询。它从所有POI函数中删除amenities参数。 tags字典接受以下形式的key:value对:

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

新的POI查询功能的使用示例:

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)

答案 2 :(得分:0)

您可以轻松做到这一点,我认为:

#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"]