Skip to main content

Fetching and aggregation of traffic data from Finnish roads

Project description

Python package for:

  1. fetching raw historical traffic data from Finnish Transport Infrastructure Agency,

  2. aggregating said data,

  3. building directional graph between provinces/ervas and mapping the edges to the appropriate sections of the aggregated traffic data, and

  4. visualizing the aggregated data.

Installation

pip3 install fin-traffic-data

Fetching raw traffic data

The console script fin-traffic-fetch-raw-data allows you to fetch the raw traffic data of all traffic measuring stations between two dates. Usage:

fin-traffic-fetch-raw-data --begin-date 2020-01-01 --end-date 2020-02-01

The dates are formatted as YYYY-MM-DD. The script spits out HDF5 files storing pandas dataframes with the filenaming convention fin_traffic_raw_<begin-date>_<end_date>.h5.

The output file contains the raw traffic data for each TMS in a dataset called tms_<tms id>.

Aggregating raw data

The console script fin-traffic-aggregate-raw-data allows you the aggregate pre-fetched traffic data. Usage:

fin-traffic-aggregate-raw-data --dir raw_data/ --time-resolution 1h

Here the options are

–dir

Directory from which to load the datafiles for raw traffic data

–time-resolution

Time-resolution of the aggregation. Use the literals w for weeks, d for days, and h for hours.

The script spits out a file named fin_traffic_aggregated_<begin-date>_<end-date>_<time-resolution>.h5.

Computing traffic between provinces and university hospital catchment areas

The console script fin-traffic-compute-traffic-between-areas can be used to compute traffic between different regions. For computing traffic between provinces, use the command:

fin-traffic-compute-traffic-between-areas --area province --input aggregated_data/fi_traffic_aggregated-2020-01-01 00:00:00-2020-09-16 00:00:00-1:00:00.h5

For traffic between university hospital catchment areas, use the flag –area erva. This tool spits out a file named tms_between_ervas.h5 or tms_between_provinces.h5.

Converting province/ERVA level traffic to CSV format

For converting province/ERVA level traffic to a compressed archive of CSV-files, use the command:

fin-traffic-export-traffic-between-areas-to-csv --area erva

This requires the file tms_between_ervas.h5 and outputs the archive tms_between_ervas.tar.bz2.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fin_traffic_data-0.0.3.tar.gz (12.9 kB view details)

Uploaded Source

Built Distribution

fin_traffic_data-0.0.3-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file fin_traffic_data-0.0.3.tar.gz.

File metadata

  • Download URL: fin_traffic_data-0.0.3.tar.gz
  • Upload date:
  • Size: 12.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for fin_traffic_data-0.0.3.tar.gz
Algorithm Hash digest
SHA256 49b727c2475bf9d6c5748a0d61f85c25adb288cb15aace757e2ab9370340bcda
MD5 0593399ca2517cdb1fdea222df9887f7
BLAKE2b-256 3aff8ed0def0095f7149ddd8bec27ab6c8f7e85c73e94c502287ae8dbed9f8e1

See more details on using hashes here.

File details

Details for the file fin_traffic_data-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: fin_traffic_data-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 14.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.8.5

File hashes

Hashes for fin_traffic_data-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d0bf90ed5c13f1af3f1db008583390e38e6ebbc701cb6f9b1690cd7e06a647ea
MD5 ec1be41e8f2901a28e0fb5d34cd2661d
BLAKE2b-256 1a89d84e9ab512bd4d67aedf6179db6d14eb60c4dd8cf03d9a95122e027095cd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page