Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError in Network.calc_net_stats() --> dict for node2coords? #32

Closed
jGaboardi opened this issue Nov 11, 2020 · 0 comments
Closed

IndexError in Network.calc_net_stats() --> dict for node2coords? #32

jGaboardi opened this issue Nov 11, 2020 · 0 comments

Comments

@jGaboardi
Copy link
Owner

Probably should convert all lookups to dictionaries from lists. Not sure why I made all these lists in dissertation implementation...

See also #29

To reproduce:

bbox = (-84.279,30.480,-84.245,30.505)
f = "zip://test_data/Edges_Leon_FL_2010.zip!Edges_Leon_FL_2010.shp"
gdf = geopandas.read_file(f, bbox=bbox)
gdf = gdf.to_crs("epsg:2779")
yes_roads = gdf["MTFCC"].str.startswith("S")
roads = gdf[yes_roads].copy()

kwargs = {"s_data": roads.copy(), "from_raw": True}
attr_kws = {"attr1": ATTR1, "attr2": ATTR2}
kwargs.update(attr_kws)
comp_kws = {"record_components": True, "largest_component":True}
kwargs.update(comp_kws)
graph_elems_kws = {"def_graph_elems": True}
kwargs.update(graph_elems_kws)
geom_kws = {"record_geom": True, "calc_len": True}
kwargs.update(geom_kws)
mtfcc_kws = {"discard_segs": discard_segs, "skip_restr": SKIP_RESTR}
mtfcc_kws.update({"mtfcc_split": INTRST, "mtfcc_intrst": INTRST})
mtfcc_kws.update({"mtfcc_split_grp": SPLIT_GRP, "mtfcc_ramp": RAMP})
mtfcc_kws.update({"mtfcc_split_by": SPLIT_BY, "mtfcc_serv": SERV_DR})
kwargs.update(mtfcc_kws)
net = tigernet.Network(**kwargs)
net.calc_net_stats()
IndexError                                Traceback (most recent call last)
<ipython-input-84-bab5579caf99> in <module>
     14 kwargs.update(mtfcc_kws)
     15 net = tigernet.Network(**kwargs)
---> 16 net.calc_net_stats()

~/tigernet/tigernet/tigernet.py in calc_net_stats(self, conn_stat)
    622 
    623         # Calculate the sinuosity of network segments and provide descriptive stats
--> 624         stats.calc_sinuosity(self)
    625 
    626         # Set node degree attributes

~/tigernet/tigernet/stats.py in calc_sinuosity(net)
     18     # Calculate absolute shortest path along segments
     19     # Euclidean distance from vertex1 to vertex2
---> 20     net.s_data = utils.euc_calc(net, col="euclid")
     21 
     22     # Calculate sinuosity for segments

~/tigernet/tigernet/utils.py in euc_calc(net, col)
   1274     net.s_data[col] = numpy.nan
   1275     for (seg_k, (n1, n2)) in net.segm2node:
-> 1276         p1, p2 = net.node2coords[n1][1][0], net.node2coords[n2][1][0]
   1277         ed = _euc_dist(p1, p2)
   1278         net.s_data.loc[(net.s_data[net.sid_name] == seg_k), col] = ed

IndexError: list index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant