Skip to content

Usage: 7. Visualising Network

Kasia Kozlowska edited this page Dec 18, 2020 · 7 revisions

This page goes through examples of visualising networks in GeNet. Also available as a jupyter notebook.

# read sample network
from genet import Network
import os

n = Network('epsg:27700')
path_to_matsim_network = '../example_data/pt2matsim_network'
n.read_matsim_network(os.path.join(path_to_matsim_network, 'network.xml'))
n.read_matsim_schedule(os.path.join(path_to_matsim_network, 'schedule.xml'))

Basic plots

Each GeNet class has a plot method.

n.plot()

n.schedule.plot()

n.schedule['12430'].plot()

n.schedule.route('VJ948e8caa0f08b9c6bf6330927893942c474b5100').plot()

GeNet Network can an additional two methods to

  • just plot the underlying graph and
  • to plot the un-routed schedule on top of the graph
n.plot_graph()

n.plot_schedule()

Standard Outputs

You can generate a long list of outputs which are useful for validating and visualising the network and its schedule.

n.generate_standard_outputs(output_dir='path/to/standard_outputs', gtfs_day='19700101')

Specifying gtfs_day is optional and only useful for generating visualisations which don't rise eyebrows. In this bundle you get a number of outputs which you can drop into kepler.gl or qgis:

  • network graph related
    • geojsons for car mode featuring 'freespeed', 'capacity', 'permlanes' (separately, because these can get large)
    • geojsons for all other modal subgraphs
  • schedule related
    • geojsons and shapefiles featuring schedule graph with vehicles per hour for every mode separately and all together (with mode data present) in the schedule for all hours of the day, this can be used within kepler to animate across hours of the day. (Use 'filter' option on 'hour' field and click on the little clock)
    • the same as above for all modes together but subsetted for am/inter/pm peak within hours 7, 8, 9, 13, 16, 17, 18 for convenience (in case the big geojson may be too large to load in kepler)
    • png bar plots for vehicles per hour per:
      • PT service
      • PT stop (titles and file names include modes and human readable names for stops and services if present)

You can also generate standard outputs for schedule only:

n.schedule.generate_standard_outputs(output_dir='path/to/standard_outputs', gtfs_day='19700101')