【发布时间】:2017-12-07 20:46:33
【问题描述】:
我正在尝试关注“Pandana 网络可访问性演示”Github 存储库 (https://github.com/gboeing/urban-data-science/blob/2017/20-Accessibility-Walkability/pandana-accessibility-demo-full.ipynb)。
到目前为止,复制和粘贴代码时一切正常,但运行时出现问题:
start_time = time.time()
if os.path.isfile(net_filename):
# if a street network file already exists, just load the dataset from that
network = pandana.network.Network.from_hdf5(net_filename)
method = 'loaded from HDF5'
else:
# otherwise, query the OSM API for the street network within the specified bounding box
network = osm.network_from_bbox(bbox[0], bbox[1], bbox[2], bbox[3])
method = 'downloaded from OSM'
# identify nodes that are connected to fewer than some threshold of other nodes within a given distance
lcn = network.low_connectivity_nodes(impedance=1000, count=10, imp_name='distance')
network.save_hdf5(net_filename, rm_nodes=lcn) #remove low-connectivity nodes and save to h5
print('Network with {:,} nodes {} in {:,.2f} secs'.format(len(network.node_ids), method, time.time()-start_time))
这是我得到的错误:
AttributeError Traceback (most recent call last)
<ipython-input-7-693cbbc8dc72> in <module>()
10
11 # identify nodes that are connected to fewer than some threshold of other nodes within a given distance
---> 12 lcn = network.low_connectivity_nodes(impedance=1000, count=10, imp_name='distance')
13 network.save_hdf5(net_filename, rm_nodes=lcn) #remove low-connectivity nodes and save to h5
14
AttributeError: 'tuple' object has no attribute 'low_connectivity_nodes'
【问题讨论】:
-
正如它所说的:
network是一个元组(Python 预定义的数据类型)。元组没有这样的方法。我们不能做更多,因为您没有提供Minimal, complete, verifiable example,而且我们不知道什么数据类型会有这样的方法,或者你认为你是如何进入的network. -
笔记本使用 pandana (v0.2) 从 OpenStreetMap API (OSM API) 下载街道网络和兴趣点 (POI) 数据,然后计算兴趣点的网络可访问性。如果有人可以帮助我,我将链接附加到问题中的回购。
标签: python python-2.7 attributes tuples