Code Monkey home page Code Monkey logo

ports_project's Introduction

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.

ports_project's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.