spara / ports_project

utility scripts for HERE Traffic Analytics and NavStreets

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Traffic Analytics and NavStreets

This project is a set of utility scripts for:

To run the notebooks

  1. Create a Python3 virtual environment
$ python3 -m venv venv
$ pip install -r requirements.txt
$ source venv/bin/activate
  1. Start Jupyter
$ jupyter notebook

Step 1: Requesting data from the Traffic Analytics API

The get traffic analytics data notebook uses a geojson file with one feature per line:

{ "type": "Feature", "properties": { "OBJECTID": 1, "COUNT": 1, "SHAPE_Length": 0.92073356600019451, "SHAPE_Area": 0.050308487050890478, "NAME": "box" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 0, 0 ], [ 0, 1 ], [ 1, 1 ], [ 1, 0 ] ] ] } }
{ "type": "Feature", "properties": { "OBJECTID": 1, "COUNT": 1, "SHAPE_Length": 0.92073356600019451, "SHAPE_Area": 0.050308487050890478, "NAME": "another_box" }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 1, 1 ], [ 1, 2 ], [ 2, 2 ], [ 2, 1 ] ] ] } }

The script extracts the coordinates of the polygon to create the body of the Traffic Analytics API request using template.json as a starting point. It also sets the start and end date for the query. The script can be modified to set other parameters of the query.

Note that the notebook currently only prints out the requests. The Traffic API does not handle multiple requests and the section for sending requests has been commented out. The accompanying get traffic analytics script should not be used until the the API can handle multiple requests.

Step 2: Calculating congestion scores

The congestion score is calculated from the Traffic Analytics data stored in this directory.

congestion metric is: 1 βˆ’ πΆπ‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘π‘†π‘π‘’π‘’π‘‘/πΉπ‘Ÿπ‘’π‘’πΉπ‘™π‘œπ‘€π‘†π‘π‘’π‘’π‘‘ (floor at 0)

weighted congestion by length of road segment: βˆ‘π‘†π‘’π‘”π‘šπ‘’π‘›π‘‘πΏπ‘’π‘›π‘”π‘‘β„Ž βˆ—(1 βˆ’πΆπ‘’π‘Ÿπ‘Ÿπ‘’π‘›π‘‘π‘†π‘π‘’π‘’π‘‘πΉπ‘Ÿπ‘’π‘’πΉπ‘™π‘œπ‘€π‘†π‘π‘’π‘’π‘‘)γ€—

These scores are added to the traffic analytics data and saved to the same directory.

Step 3: Preparing NavStreets for joining congestion scores

The traffic data have to and from road LINK-IDs. These fields must be added to the NavStreets data to join the congestion data to display the data on a map. The HERE_Streets_to_TA notebook adds and populates these field. The NavStreets data should be clipped to the area of interest in the reference file to reduce the amount of processing.

Step 4: Joining congestion scores to NavStreets

The join and export geojson notebook joins the updated StreetsNav file to the congestion data and exports the dataframe as a geojson file. The output file has only the minimum needed to display the data in a web mapping application.

About

utility scripts for HERE Traffic Analytics and NavStreets


Languages

Language:Jupyter Notebook 100.0%