Intersection Insights analyzes whether closely spaced traffic signals are associated with higher accident risk in urban environments.
The project combines geospatial analysis, statistical testing, and a desktop visualization tool to explore real-world traffic safety questions using open municipal data.
📍 Case studies: Ottawa (primary) and Brampton (motivating example)
The idea originated from a real-life close call at an intersection in Brampton — where short spacing between traffic lights likely contributed to a missed red light. That experience sparked the question:
Does short spacing between traffic lights increase driver confusion and accident risk?
Are intersections with traffic signals spaced less than 200 meters apart associated with higher accident rates?
-
Interactive Desktop GUI
- Tkinter-based interface
- Drop pins to select locations
- Adjustable distance thresholds and search radius
-
Custom Geospatial Analysis
- Traffic signal clustering using DBSCAN
- Distance-based flagging (25–200m)
-
Automated Statistical Testing
- Chi-square test
- Mann–Whitney U test
- Stratified distance-group analysis
-
Geospatial Visualization
- OSMnx + Folium maps
- Accident heatmaps
- Flagged intersection overlays
Figure 1: The interactive Tkinter GUI landing page, allows users to provide a distance between lights (meters) and a radius (meters)
Figure 2: Users can select a location to analysis by adding a marker
Figure 3: A selected location is shown as a red marker
-
The methodology is city-agnostic and can be applied to any municipality with:
- Open traffic signal data (OpenStreetMap)
- Collision datasets with latitude/longitude
-
Ottawa is used as the primary case study because:
- High-quality, publicly available accident data
- Consistent formatting and precise geolocation
🔎 Cities like Toronto, Vancouver, or NYC could be analyzed using this same pipeline.
| Step | Description |
|---|---|
| 1 | Pull traffic signal data from OpenStreetMap |
| 2 | Cluster nearby signals into intersections using DBSCAN |
| 3 | Flag intersections with signals spaced 25–200m apart |
| 4 | Match accidents to intersections via lat/lon |
| 5 | Apply buffer analysis (25m, 50m, 100m, 200m) |
| 6 | Filter to signal-controlled intersections only |
| 7 | Run statistical tests (Chi-square, Mann–Whitney U) |
| 8 | Visualize flagged intersections + accident heatmaps |
| Hypothesis | Result | Statistically Significant? |
|---|---|---|
| Flagged vs. non-flagged intersections have more accidents | ❌ Not supported | p > 0.05 |
| Closer spacing (e.g., 50–100m) leads to more accidents | ❌ No trend | p > 0.05 |
| Flagged intersections more dangerous at night | ❌ No difference in lighting conditions | p > 0.05 |
| Flagged intersections align with accident hotspots | Visual only |
Figure 4: Shows accident density (heatmap) with flagged intersections by spacing group.
- 🔴 50–100m
- 🟠 100–150m
- 🟣 150–200m
Observation: No observations of area with many accidents
Figure 5: Bar chart comparing lighting conditions at flagged vs. non-flagged intersections.
Observation: Both have similar distributions — most accidents happen in daylight, not at night.
Traffic light spacing alone is not a predictor of higher accident rates in Ottawa. Lighting conditions and distance buckets (50–200m) did not significantly affect accident likelihood.
- Tested whether flagged intersections had a higher chance of ≥1 accident.
- Result: No significant difference (p > 0.05)
- Tested whether accident counts per intersection differed across groups.
- Result: No significant difference between flagged and non-flagged groups.
- Measured % of intersections with ≥1 accident in each distance group.
- No distance group showed significantly more risk.
- Compared lighting condition at time of accidents (day/dusk/night).
- Both flagged and non-flagged intersections showed similar distributions.
- Apply to other cities (Toronto, Vancouver, NYC)
- Integrate accident text descriptions via NLP to detect signal confusion
- Partner with municipalities for dashboard pilot
- Explore human factors & visual psychology research to support design changes
| File | Purpose |
|---|---|
filtered_route_violations_50_200m.csv |
Intersections flagged for proximity |
accidents_exactly_at_intersections.csv |
Accident matches at flagged intersections |
flagged_intersections_with_closest_distance_group.csv |
Final grouped summary for analysis |
ottawa_accident_heatmap_with_flagged_intersections.html |
Interactive map |
accident_summary_by_distance_group.csv |
Stratified summary |
flagged_intersection_vs_non_flagged_intersection_MannWhitneyU.csv |
Mann-Whitney test results |
git clone https://github.com/your-username/traffic-light-proximity.git
cd traffic-light-proximityconda create -n traffic-geo python=3.10 -y
conda activate traffic-geoconda install -c conda-forge \
osmnx \
geopandas \
folium \
matplotlib \
shapely \
networkx \
scikit-learn \
scipy \
geopy \
ipykernel -ypip install tkintermapviewNote:
tkinteris included with most Python distributions. If you encounter errors:
- On macOS:
brew install python-tk- On Ubuntu/Debian:
sudo apt-get install python3-tk- On Windows: It should already be available.
python main.py- Open the folder in VS Code.
- Press
Ctrl + Shift + P→ search forPython: Select Interpreter. - Choose the
traffic-geoconda environment. - Run your script from the integrated terminal.
All generated files (CSV summaries, heatmaps, charts, maps, and GeoJSON) will be saved to your selected export directory. Key outputs include:
ottawa_traffic_lights.geojsonfiltered_route_violations_50_200m.csvaccident_counts_per_intersection.csvottawa_map.html(folium interactive map)lighting_condition_bar_chart.png- Summary tables and stratified analysis CSVs
