This Clay Notebook project analyzes California's crash data (CCRS) with a focus on Oakland's Grand Ave and Telegraph Ave. The project demonstrates practical techniques for working with real-world GIS data in Clojure, including handling missing coordinates, messy street names, and spatial matching.
🔗 View the Live Site (GitHub Pages)
- Tutorial: Comprehensive guide to GIS data handling techniques used in this project
- Main Analysis: Full crash analysis for Grand Ave and Telegraph Ave with interactive maps
This project shows how to handle common real-world GIS challenges:
- Missing Coordinates: Derive locations from street intersection names using spatial matching
- Messy Street Names: Normalize and clean inconsistent text data
- Coordinate System Transformations: Use local projected coordinates for accurate spatial operations
- Spatial Indexing: R-tree indexes for efficient polygon/point queries
- Buffer-Based Matching: Fuzzy spatial matching for imperfect data
-
Process California’s Crash Data (CCRS):
- Analyze trends on Telegraph Ave before and after traffic calming measures were implemented.
-
Examine Current Crash Patterns on Grand Ave:
- Investigate the affected demographics, such as age groups.
-
Visualize and Interpret Findings:
- Create visualizations to help interpret the analyzed data and present the findings in an understandable manner.
This project combines data from three different sources:
- California Crash Reporting System (CCRS): data.ca.gov
- Crashes, parties, and injured persons data (2015-2024)
- Oakland-filtered datasets in
datasets/directory
- Alameda County Street Centerlines: data.acgov.org
- GeoJSON with street geometries for Alameda County
- Filtered to Oakland city limits (see
notebooks/data.clj)
- Oakland Neighborhood Boundaries: OpenOakland
- Polygon data for neighborhood assignment (CEDA 2002 neighborhoods)
This project uses Clay (Clojure notebooks) + Quarto to generate static HTML for GitHub Pages.
- Edit notebooks in
notebooks/(e.g.,tutorial.clj,index.clj) - Generate QMD: In Emacs, call
clay-make-ns-htmlon the namespace- This creates
.qmdand.htmlfiles indocs/
- This creates
- Build full site: Run
quarto renderin thedocs/directory- Generates complete site with navigation, search, etc.
- Deploy: Push to GitHub - Pages automatically serves from
/docs
# Install dependencies
clj -P
# Generate a single notebook (or use clay-make-ns-html in Emacs)
clj -M:clay ...
# Build the full Quarto site
cd docs
quarto rendergrand-ave/
├── notebooks/ # Clay/Clojure notebooks
│ ├── tutorial.clj # GIS methodology tutorial
│ ├── index.clj # Main analysis
│ ├── data.clj # Data loading utilities
│ └── locations.clj # Advanced spatial analysis
├── datasets/ # Oakland crash data CSVs (2015-2024)
├── data/ # GIS reference data (neighborhoods, streets)
├── docs/ # Generated site (GitHub Pages)
└── deps.edn # Clojure dependencies
How did crash rates change on Telegraph Ave before and after the lane reduction?
Did the number of injuries and fatalities decrease after the redesign?
What types of crashes (e.g., pedestrian-involved, cyclist-involved, rear-end collisions) were most affected?
Did crash severity change (e.g., more minor crashes, fewer fatal ones)?
What are the most common types of crashes on Grand Ave?
Who is most affected (age groups, pedestrian/cyclist involvement, vehicle occupants)?
What locations along Grand Ave see the most crashes?
Are there trends in crash timing (e.g., peak hours, weekends vs. weekdays)?
How do crash rates on Grand Ave compare to pre-road-diet Telegraph?
How do total crash numbers compare between the two corridors?
Are the types of crashes similar, or does one street see different patterns?
Who is most at risk on each street?
Based on Telegraph’s data, what safety improvements could be predicted for Grand Ave if a similar lane reduction were implemented?
This analysis focuses on two main areas:
-
Telegraph Ave: Analyze crash trends before and after traffic calming measures (road diet)
- KONO district (19th-29th St)
- Pill Hill district (29th-41st St)
-
Grand Ave: Examine current crash patterns and affected demographics
- Harrison to Mandana Boulevard section
- Focus on pedestrian and bicycle safety
This project serves as a practical example of:
- Working with government open data in Clojure
- Handling imperfect geographic data
- Using JTS (Java Topology Suite) through the
geolibrary - Creating interactive visualizations with Clay/Quarto
- Building static data science sites with GitHub Pages
Key libraries used:
scicloj/noj- Data science toolkitfactual/geo- GIS operations and JTS wrapperscicloj/tablecloth- DataFrame operationsscicloj/clay- Notebook generation
This project was created for a presentation at a Clojure data science conference. If you're working on similar GIS problems in Clojure, feel free to open issues or discussions!
Data is from public government sources. Code examples are provided for educational purposes.