我正在尝试使用pandana软件包来测量道路网络中不同兴趣点的可访问性。
问题在于此过程无法将可访问性分配给我们定义的所有pois。特别是在这里,我们定义了100 pois,我们只能获得其中的84 pois。
我从开放的街道地图中定义了一个网络。
# Bounding box for a small area in East Emeryville, South Berkeley and North Oakland
west, south, east, north = (-122.285535, 37.832531, -122.269571, 37.844596)
# Create a network from that bounding box
G = ox.graph_from_bbox(north, south, east, west, network_type='walk')
# Let's create n arbitrary points of interest (POI)
poi_count = 100
# this function makes those POI into Shapely points
def make_n_pois(north, south, east, west, poi_count):
for poi in range(poi_count):
x = (east - west) * random.random() + west
y = (north - south) * random.random() + south
yield Point(x, y)
pois = list(make_n_pois(north, south, east, west, poi_count))
fig, ax = ox.plot_graph(G, fig_height=10,
show=False, close=False,
edge_color='#777777')
for point in pois:
patch = PolygonPatch(point.buffer(0.0001), fc='#ff0000', ec='k', linewidth=0, alpha=0.5, zorder=-1)
ax.add_patch(patch)
然后我将pois设置为网络。
nodes_gdf, edges_gdf = ox.graph_to_gdfs(G)
# Instantiate a Pandana (pdna) network (net)
net = pdna.Network(nodes_gdf['x'], nodes_gdf['y'],
edges_gdf['u'], edges_gdf['v'],
edges_gdf[['length']])
pois_df = pd.DataFrame(pois)
pois_df.columns = ['geometry']
pois_df=gpd.GeoDataFrame(pois_df)
pois_df['x']=pois_df['geometry'].x
pois_df['y']=pois_df['geometry'].y
## Measuring Accessibility
net.set_pois(category='pois', maxdist=30000, maxitems=1, x_col=pois_df['x'], y_col=pois_df['y'])
npi = net.nearest_pois(30000,
'pois',
num_pois=1,
include_poi_ids=True)
现在,如果我检查npi
中的点数,则仅为81
,而不是100
。
len(pd.unique(npi['poi1']))
84
为什么?