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

Can not use peartree to plot the data #155

Closed Weiji-a closed 4 years ago

Weiji-a commented 4 years ago

Hello,

I am trying to using peartree to plot the GTFS data, but in the end I meet this error


UnboundLocalError`                         `Traceback` `(most` recent call last)
<ipython-input-12-3fede03b6b3a> in <module>
----> 1 pt.generate_plot(G)

~\Anaconda3\lib\site-packages\peartree\plot.py in generate_plot(G, use_agg)
     25     #       also plan on incorporating OSMnx into this library
     26     #       down the road so it isn't too extraneous an import.
---> 27     fig, ax = ox.plot_graph(G,
     28                             fig_height=12,
     29                             `show=False,`
UnboundLocalError: local variable 'ox' referenced before assignment
Weiji-a commented 4 years ago

And the code is

import pandas as pd
import numpy as np
import networkx as nx
import peartree as pt
path = 'C:/Users/Administrator/Desktop/fr-idf_gtfs.zip'
feed = pt.get_representative_feed(path)

# Set a target time period to
# use to summarize impedance
start = 7*60*60  # 7:00 AM
end = 10*60*60  # 10:00 AM

# Converts feed subset into a directed
# network multigraph
G = pt.load_feed_as_graph(feed, start, end)
pt.generate_plot(G)
invisiblefunnel commented 4 years ago

You probably need to install the osmnx package. It is an optional dependency of peartree: https://github.com/kuanb/peartree/blob/0c5073d8b62a49ea299e8e2c2df1369fc4dcb3ea/peartree/plot.py#L13-L20.

kuanb commented 4 years ago

Thanks @invisiblefunnel

adarshyadav2705 commented 1 year ago

Hey, @invisiblefunnel it worked, but I found that the graph image I am getting has just 14 nodes. How do I resolve it to get the complete graph of the full network