Analyze NextBike trips in your city: collect, process, and visualize bike trips.
- collection/ # Setup data collection
- data/ # Stored trips data
- docs/ # Documentation
- processing/ # Calculate trips
- visualization/ # Web visualization- Docker with Compose (Install Docker)
-
Clone the repository:
git clone https://github.com/zwoefler/nextbike-city-analysis.git cd nextbike-city-analysis -
Create your
.envfile:cp .env.example .env
Edit
.envand set your values:Variable Description DB_USERPostgres username DB_PASSWORDPostgres password DB_NAMEPostgres database name DB_HOSTPostgres host ( nextbike_postgreswhen using compose)DB_PORTPostgres port (default: 5432)DB_BIKES_TABLETable name for raw bike data DB_STATIONS_TABLETable name for station data DB_CITIES_TABLETable name for city data CITY_IDSComma-separated Nextbike city IDs to collect, e.g. 467,210STATIONS_SYNC_INTERVAL_HOURSHow often to sync stations CITIES_SYNC_INTERVAL_HOURSHow often to sync city metadata EXPORT_DIROutput folder for processed trip files (default: /data)VISUALIZATION_PORTPort for the web UI (default: 8080)Find your city ID in
city_ids_2025_02_15.md. -
Start everything:
docker compose up -d
This starts four services:
- postgres - database for raw bike, station, route, and trip data
- collector - polls the Nextbike API every 60 seconds and writes to postgres
- processor - runs at midnight; calculates trips for each city in
CITY_IDS, caches OSM routes in the database, and writes.geojson.gzfiles to thetrip_datavolume - visualization - FastAPI app at
http://localhost:${VISUALIZATION_PORT}that serves trip and station data live from the database
-
Open
http://localhost:8080(or your configuredVISUALIZATION_PORT) in your browser.⚠ To trigger
processingmanually, see docs/manual-processing.md.
# Stop containers
docker compose down
# Stop and delete all data (including the database volume)
docker compose down -v --remove-orphansInspired by 36c3 - Verkehrswende selber hacken by ubahnverleih & robbie5.
Visualization inspired by Technologiestiftung Berlin: