This code calculates cycling Level of Traffic Stress for all road and path segments in a region using data from Open Street Map.
This code is adapted from Bike Ottawa's LTS code, modified to include Level of Traffic Stress for intersections.
- Generate an OSM query file for the region you want to study.
- Go to openstreetmap.org, search for the region you want to download (i.e. "Victoria"), then find the matching region in the list on the left side.
- Click on the region you want, which should open a page for a
relationthat says something like "Relation: Victoria (2221062)" at the top. - Scroll down in the list of tags until you findwikidata, i.e.wikidata:Q2132for Victoria, Canada. - In a terminal, run
build_query.pywith this key-value pair: runpython build_query.py victoria wikidata Q2132to generate a filevictoria.query.
- Download OSM data to get a list of tags. In a terminal, run
wget -nv -O victoria.osm --post-file=victoria.query "http://overpass-api.de/api/interpreter", changing the input and output filenames as needed. - Change the city name in the script
LTS_OSM.py. RunLTS_OSM.pyto download the network for the region and calculate LTS. This outputs a dataframe calledall_lts.csvwhich contains all the ways, their assigned LTS, and the decision criteria that led to that LTS. In particular, the columnslanesandmaxspeedmay containNaNif this information is not present in the OSM tags and the data can be filtered to exclude these. - Plot resulting LTS map with
LTS_plot.py. - Plot an isochrone map for different LTS thresholds with
isochrone.py. This requires both the saved graph object and the dataframe with LTS levels calculated.
This code is under active development. Check out the Issues for a list of improvements that will be made soon.