Skip to content

NextBike data analysis for your city. Includes Data gathering, aggregation, cleanup and display.

License

Notifications You must be signed in to change notification settings

mzwoelfer/nextbike-city-analysis

 
 

Repository files navigation

Nextbike city analysis

NextBike trip analysis for your city. Collect, process and visualize bike trips in your City.

This project pulls data from the public Nextbike API and aggreagtes it into "trips". Then the data can be previewed on a map. Or you can use the data in csv format to do your own analysis in Excel.

Overview

- collection/           # Setup Nextbike API data collection on a server
- data/                 # Nextbike trips data
- docs/                 # Documentation
- processing/           # Calculate trips from data in database
- visualization/        # Webpage to visualize the trips

Prerequisites

Development

  1. Clone Repository: git clone [email protected]:zwoefler/nextbike-city-analysis.git
  2. Change directory: cd nextbike-city-analysis/
  3. Change into directory for development. collection/ or processing/
  4. Create python virtual environment:
python3 -m venv Env
source Env/bin/activate
pip install -r requirements.txt

🚀 Getting started / Install

  1. Clone repo:
git clone https://github.com/zwoefler/nextbike-city-analysis.git
cd nextbike-city-analysis
  1. Setup data collection:
# Change directory into collection
cd collection

# Copy the fake env vars
cp .env.example .env

# Start data aggregation in background. Pulls & builds the images
docker compose --file docker-compose.yaml up -d

# cd back to project root
cd ..
  1. Set city_id and date to today as shell variables:
# Use format YYYY-MM-DD.
date='2025-01-07'
city_id=467
  1. Calculate trips (Wait a few minutes before execution):
cd data_processing

python3 -m nextbike_processing.main --city-id $city_id --export-folder ../data/trips_data/ --date $date

cd ..
  1. Visualize trips:
# Copy data to visualization data
cp "data/trips_data/${city_id}_trips_${date}.json" visualization/data/
cp "data/trips_data/${city_id}_stations_${date}.json" visualization/data/

Change into visualization/ and sstart the server to display the map:

python3 -m http.server 8000
  1. Visit localhost:8000 in your browser.

Credits

Inspiration: 36c3 - Verkehrswende selber hacken talk by

🫵🏽 Check them out. An absolute treasure for mobility focused IT projects!

Technical inspiration from the great visualization by Technologiestiftung Berlin. Especially their two projects:

About

NextBike data analysis for your city. Includes Data gathering, aggregation, cleanup and display.

Topics

Resources

License

Stars

Watchers

Forks

Languages

  • Python 38.4%
  • JavaScript 38.3%
  • HTML 10.8%
  • CSS 8.1%
  • Shell 4.4%