Inspiration
As Yale students ourselves, our team knows too well the unavoidable late nights in New Haven. Whether it is a late night bite at Shah's Halal or the final minutes before a PSet submission in Bass Library, we find ourselves navigating through the both familiar and unfamiliar streets of New Haven at late hours. It is at these times of day that the the “shortest route” does not mean the route that feels safest. Especially with New Haven's high crime rates, we wanted a tool that helps Yale students plan walking routes that account for neighborhood-level safety risk, using real map data and an explainable model.
What it does
SafeWalking is a crime-aware walking route planner for New Haven centered around Yale's camp. SafeWalking loads real street networks from OpenStreetMap, colors street segments by relative safety risk, and lets users select their route by clicking the map or typing in the addresses of their starting and ending destinations. SafeWalking then finds the “safest reasonable route” using a weighted shortest-path algorithm that combines distance and a safety. Upon finding the optimal route, SafeWalking will show a route summary that includes the distance, segments, the crime score, and a safety rating.
How we built it
- Frontend + mapping
- Built the UI and interactive map using HTML/CSS/JavaScript + Leaflet
- Rendered the base map with OpenStreetMap tiles
- Drew street segments as polylines with popups for street + neighborhood + risk score
- APIs + real map data
- Pulled road geometry from the Overpass API (OpenStreetMap road “ways” + “nodes”) inside a bounding box around Yale/New Haven
- Converted typed addresses and clicked locations to coordinates using Nominatim (geocoding + reverse geocoding)
- Neighborhood-aware safety model
- Defined neighborhood polygons and used Turf.js point-in-polygon to assign each street segment to a neighborhood based on its midpoint
- Applied neighborhood safety factors derived from published crime-rate comparisons, then generated a deterministic per-segment “crime score” (so the same street stays consistent across reloads)
- Routing
- Built a graph where nodes = intersections, edges = street segments, and edge weight = crime penalty + distance penalty *Ran Dijkstra’s algorithm to compute the minimum-cost path (safe + not absurdly long)
Challenges we ran into
One of our biggest challenges was access to granular crime data. That is, we were not able to obtain a clean, public dataset with exact crime incident locations (latitude/longitude) for New Haven that was easy to use within hackathon time constraints. Because of this, we couldn’t directly count crimes per street segment, which was our original goal. Instead, we built a neighborhood-level safety model and generated deterministic per-street crime scores based on neighborhood risk factors. To simulate realistic variation between streets while keeping results stable, we used a coordinate-based pseudo-random method. For each street segment, we calculate its midpoint, determine which neighborhood polygon it falls inside, and apply that neighborhood’s safety factor. We then generate a consistent “random-looking” value by passing the latitude and longitude through a mathematical hash using sine and cosine functions. This produces a number between 0 and 1 that is always the same for that location, meaning the same street will always receive the same risk score. That value is scaled by the neighborhood safety factor to produce a final crime score for the segment. In addition, in regard to neighborhood boundaries, real GIS polygons are complex, so we had to approximate and still keep the model explainable and demo-ready. Other challenges included balancing “safe” vs “short”: we needed to tune the weight equation so the route avoids risk without sending users on ridiculous detours.
Accomplishments that we're proud of
We used real street data and generated a navigable street graph in-browser. The map is interactive and demo-friendly, allowing click-to-route, address input, popups, live stats, and a clean UI. Additionally, we tried to make risk scoring deterministic, which makes the product feel more stable and trustworthy.
What we learned
As it was our first time working with mapping systems, we learned how mapping systems work end-to-end: that is, tiles vs street geometry vs routing graphs. We also learned how to query and process OpenStreetMap using the Overpass API and how geocoding works with Nominatim.
What's next for SafeWalking
Ideally, we would swap neighborhood-level risk factors for incident-level open crime datasets and aggregate incidents to street segments while replacing approximated polygons with official New Haven neighborhood GIS boundaries. We would also like to add time-of-day safety modes such as day/evening/night weighting and let users choose preferences like “safest,” “balanced,” and “fastest”.
Built With
- and-ui-effects-javascript-(es6)-?-all-interactive-logic
- css3
- html5
- leaflet.js
- nominatim
- openstreetmap
- overpassapi
- responsive-design
- routing
- turf.js
Log in or sign up for Devpost to join the conversation.