kuanb / peartree

peartree: A library for converting transit data into a directed graph for sketch network analysis.
MIT License
201 stars 23 forks source link

Coalesce non-GTFS network #162

Open Ar-Kan opened 3 years ago

Ar-Kan commented 3 years ago

Hello,

When I try to use the coalesce function on a path network from OSM the following error is raised:

KeyError                                  Traceback (most recent call last)
c:\Users\arqui\Documents\Repositorios\Identifying urban zones with spectral clustering\coalesse_poa.py in 
      81     # network_type='walk'
      82 )
----> 83 Gc = pt.toolkit.coalesce(G, 400)

~\anaconda3\envs\ox\lib\site-packages\peartree\toolkit.py in coalesce(G_orig, resolution, edge_summary_method, boarding_cost_summary_method)
    216     # such that we won't generate isolated nodes that become disconnected
    217     # from key coalesced nodes (because too many intermediary nodes)
--> 218     G = simplify_graph(G)
    219 
    220     # Extract all x, y values

~\anaconda3\envs\ox\lib\site-packages\peartree\toolkit.py in simplify_graph(G_orig)
    582         # If the path is not all one mode of travel, skip the
    583         # proposed simplification
--> 584         if not _path_has_consistent_mode_type(G, path):
    585             continue
    586 

~\anaconda3\envs\ox\lib\site-packages\peartree\toolkit.py in _path_has_consistent_mode_type(G, path)
    364         for i in range(edge_count):
    365             edge = G.edges[u, v, i]
--> 366             path_modes.append(edge['mode'])
    367     path_clear = all(x == path_modes[0] for x in path_modes)
    368     return path_clear

KeyError: 'mode'

Peartree version: 0.6.3 osmnx verson: 0.16.1

It's possible to use this function on a network without GTFS information?