Mystery Incorporated


Programming, photography, news, culture, and cartoons

home | rss | atom

Add to Google

Mapping DC’s Bicycle Accidents


February 17th, 2013 [programming]

statmapperWhen TheWashCycle blog reported on the Bicycle Crash Study 2010-2012, I was surprised to see the report didn’t include a map. So, I created a tool to view a map of the accident locations: the Stat Mapper.

I got a copy of the source data from DDOT. It covers January 6, 2010 to March 31, 2012. That period has 1,087 accidents in 744 locations. The report lists locations using text descriptions of the intersections. To convert into latitude & longitude coordinates for the map, I relied on Google’s geocoder. These results aren’t always accurate, especially if the text isn’t easily understood, like one accident that was recorded at “FBI:INTERSTATE 295″ (the geocoder placed that at the center of the city, but I manually moved it to 3rd & E NW).

By default the map shows a pin at every accident location. When you hover over a pin the header will show the total number of accidents there, as well as the total number of fatalities and injuries, and the number of vehicles and bicycles involved. You can click on the pin to get a full listing of all the accidents at that spot. The darker the pin, the more accidents at that location. The spot with the most accidents, nine, was at 14th & U NW.

heatmapYou can switch to viewing a heat map instead of the pins. The pins are better for viewing when zoomed in, and the heat map is better when zoomed out.

As many of the WashCycle commenters pointed out, the heat map can’t be interpreted as the most dangerous intersections, since we aren’t normalizing for the amount of traffic. An intersection with a high number of accidents could still have a low accident rate if the bike traffic is high.

WashCycle has a great post on “some limitations to the data”: Mapping DC’s Bike Crashes (as best we can).

Further Analysis

The most frequent entry for “type of collision” is “right angle,” listed for 19% of the accidents. The next-most-frequent response is “side swiped”, with 16%. The road condition is listed as “dry” in 88% of the cases, and “wet” in 9%. The weather is listed as “clear” in 89% of the cases, and “rain” in 7%.

The street lighting is listed as “off” in 65% of the cases, and “on” in 28%. The “lighting condition” is listed as “daylight” in 70% of the cases, some variation of “dark” in 25%, “dusk” in 2%, and “dawn” in 1%. The traffic is listed as “medium” in 35% of the cases, “light” in 32%, and “heavy” in 21%.

The table below shows the distribution of accidents in 2-hour segments. 27% of accidents were between 4pm and 8pm. The morning peak is between 8am and 10am, with 18% of the accidents.

accidents 34 21 5 54 192 76 96 117 181 171 84 56
hour 0:00 2:00 4:00 6:00 8:00 10:00 12:00 14:00 16:00 18:00 20:00 22:00

Coding the Map

I implemented the tool with JavaScript and the Google Maps Javascript API. This is my first time using the HeatmapLayer object.

The source data was converted from its native Excel format to a CSV file via Google Docs. I then wrote a separate program to filter the relevant rows and add the geocoded coordinates. I used the JSON object to convert the CSV array into a string, which is stored in an external javascript file.

See also Analyzing DC Bicycle Theft Data.

Leave a reply



Site by M.V. Jantzen
mvs202 "at" gmail.com
twitter.com/mvs202