AttributeError: 'tuple' 对象没有属性'low_connectivity_nodes'。

问题描述 投票:1回答:1

我正试图按照 "Pandana网络无障碍演示 "的Github repo(https:/github.comgboeingurban-data-scienceblobmaster20-Accessibility-Walkabilitypandana-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'
python python-2.7 attributes tuples
1个回答
0
投票

你可以通过以下方式解决这个错误

network = osm.network_from_bbox(bbox[0], bbox[1], bbox[2], bbox[3])
network=pandana.Network(network[0]["x"],network[0]["y"], network[1]["from"], network[1]["to"],
                 network[1][["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
© www.soinside.com 2019 - 2024. All rights reserved.