Skip to content

andr444/open-bus-tools

Repository files navigation

Bus Data Tools

Python scripts for analysing Israeli public bus data using the Open Bus Stride API — an open-data platform maintained by The Public Knowledge Workshop (Hasadna).

All scripts query live SIRI real-time GPS data and GTFS route metadata. No API key is required.


Scripts

fetch_busses_by_date_range.py

Fetches all bus GPS snapshots for a defined street corridor over a date range and saves four CSV files:

  • _busses_raw_data.csv — all snapshots (20 columns)
  • _busses_summary.csv — trip counts by route
  • _busses_not_allowed.csv — trips by non-allowed lines
  • _busses_unique.csv — one row per unique ride, most central snapshot

Supports --extend to append new dates to an existing raw CSV without re-fetching old data.

python fetch_busses_by_date_range.py 2026_04_10
python fetch_busses_by_date_range.py 2026_04_01 2026_04_30
python fetch_busses_by_date_range.py --extend from_2026.04.01_to_2026.04.30_busses_raw_data.csv 2026_05_31

street_daily_summary.py

Fetches data for a single transit day (04:00 → 03:59 next morning) and outputs:

  • A per-line summary CSV (unique trips, earliest/latest bus time)
  • An hourly breakdown CSV (rides per hour bucket, 04:00–04:00)
  • A printed table to the terminal

Configure BBOX at the top of the file to match your street.

python street_daily_summary.py 2026_04_28

street_compare_line_dates.py

Compares the number of distinct bus trips for a specific line on two dates within a street corridor, filtered by operator.

Configure BBOX and OPERATOR_NAME at the top of the file.

python street_compare_line_dates.py 29 2026_04_27 2026_04_28

Output:

  Line        2026-04-27      2026-04-28
  ----------  --------------  --------------
  29          136             141

top_speeds.py

Reads a raw data CSV and outputs the top 50 speeds, one row per unique (line_number, vehicle_ref, route_start_time) combination.

python top_speeds.py from_2026.04.01_to_2026.04.30_busses_raw_data.csv

Configuration

Each script has a BBOX constant at the top defining the geographic rectangle to query:

BBOX = dict(
    lat__greater_or_equal=32.164583,
    lat__lower_or_equal=32.165177,
    lon__greater_or_equal=34.843330,
    lon__lower_or_equal=34.847834,
)

Replace these coordinates with the diagonal corners of your street segment.

The fetch_busses_by_date_range.py script also reads an allowed_lines.csv file (one line number per row) to classify trips as allowed or non-allowed for your corridor.


Requirements

pip install requests

Python 3.8+


Data source

Open Bus Stride — open Israeli public transport data, provided by Hasadna under open licence.


License

MIT

About

Tools based on Open Bus APIs to assess bus activity at a specific location

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages