Site icon R-bloggers

Speed Cameras: Revenue or Public Safety? We’ll get you up to speed in a Flash!

[This article was first published on NYC Data Science Academy » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Goals and Introduction

Are speed cameras a tool increase safety? Or a revenue grab by local governments plugging budget deficits? With the implementation of a speed camera program in NYC and inspired by the excellent work at “I Quant NY” I decided to parse through the data and look for the answer. Two questions pervade this issue and are the focus of this analysis:

1. Are the speed cameras distributed in order to maximize public safety or revenue?

2. Have the speed cameras demonstrated any relationship with pedestrian/vehicle collision reduction?

The legislation allowing speed cameras purports to protect school-aged children by reducing pedestrian/vehicle collisions. The legislation requires cameras to operate within 1/4 mile of a school building and only during “school hours”. Consistent with this goal we would expect cameras to be distributed in areas of unusually high school density to protect the maximum amount of school children per camera. Another distribution strategy consistent with public safety would be to have the cameras distributed in areas known to have a higher than average vehicle/pedestrian collision rate. If speed camera deployment deviates from these distributions we will conclude public safety was not the primary goal of the speed camera program. Then the central premise that speed cameras increase public safety will be examined. We can compare the collision rate after the cameras were installed with the same period 1 year before camera installation. Conflicting conclusions are reported in the literature and many studies examine only speed reduction and many overlook the fundamental measure of safety, the collision rate. The speed camera data were only published from 1/16/2014 – 6/20/2014 at the time of this analysis so collision data will be compared with the prior year over the same period of time, 1/16/2013 – 6/20/2013. Only pedestrian/vehicle collisions will be analyzed as is consistent with the stated legislative goal of protecting school children and their assumption that speed cameras are an effective tool for reducing these collisions.

Data sets

<span><span><span>School.Loc Dataset:</span></span></span>
<a title="NYC School Locations Data set" href="https://data.cityofnewyork.us/Education/NYC-School-Locations/i2i8-9vjc" target="_blank"><span><span><span>https://data.cityofnewyork.us/Education/NYC-School-Locations/i2i8-9vjc</span></span></span></a>

<span><span><span>Speed.Cam Dataset:</span></span></span>
<a title="Speed Camera Tickets Data set" href="https://data.cityofnewyork.us/City-Government/Speed-Camera-Tickets/3nky-hkft"><span><span><span>https://data.cityofnewyork.us/City-Government/Speed-Camera-Tickets/3nky-hkft</span></span></span></a>

<span><span><span>Accidents Dataset:</span></span></span>
<a title="Motor Vehicle Collisions Data set" href="https://data.cityofnewyork.us/NYC-BigApps/NYPD-Motor-Vehicle-Collisions/h9gi-nx95" target="_blank"><span><span><span>https://data.cityofnewyork.us/NYC-BigApps/NYPD-Motor-Vehicle-Collisions/h9gi-nx95</span></span></span></a>

The first set of code demonstrates how NYC school locations were geocoded with the ggmap package. Due to a large number of duplicate intersections the Speed Camera data set needed to be condensed manually. Unwanted directionality (i.e. NB, SB, EB, WB) and overlapping ranges of intersections where tickets were issued (the ticket locations are coded as the street on which the ticket was issued and a range of intersecting streets) made recoding the data manually necessary. Over 80 locations were condensed to 56 intersections. Afterward the locations were geocoded in a similar fashion.

<span><span>School.Loc$Address = paste(School.Loc$Address,", New York, NY", sep="", collapse = NULL)</span></span>
<span><span>School.LonLat = geocode(School.Loc$Address)</span></span>
<span><span>School.Loc = cbind(School.Loc, School.LonLat)</span></span>
<span><span>head(School.Loc)</span></span>
                            <span>Address       lon      lat</span>
<span>1       309 47 STREET, New York, NY -73.98793 40.76086</span>
<span>2 655 PARKSIDE AVENUE, New York, NY -73.95146 40.65639</span>
<span>3 50 JEFFERSON AVENUE, New York, NY -73.95520 40.68229</span>
<span>4  820 HANCOCK STREET, New York, NY -73.92321 40.68560</span>
<span>5    43 SNYDER AVENUE, New York, NY -73.95605 40.64900</span>
<span>6  858 JAMAICA AVENUE, New York, NY -73.87311 40.68967</span>

Revenue or Safety: The Camera Distribution in NYC

The locations of the cameras were plotted with the size of the bubble representing the log of the number of tickets the camera at that location issued. As shown, Brooklyn and Queens have the highest number of cameras and the highest grossing cameras are in these boroughs on long 6 or 8-lane roadways with timed traffic lights (e.g. Queens and Northern Blvds).

nycmap = get_map(‘New York City’)
cam.map = ggmap(nycmap, extent=’device’, legend = ‘topleft’)+geom_point(aes(x=lon, y=lat, color = ‘red’, size = log(count)), data=Cam)+scale_color_discrete(‘Cameras’)

 

To understand if these speed cameras were distributed to increase school children’s safety the camera map was overlayed with the locations of NYC grade, middle, and high schools (represented as black dots). As shown, the highest density of schools is in Manhattan and the Bronx, two of the boroughs with fewer speed cameras. Clearly the cameras were not distributed to maximize the safety of school children.

school.map = ggmap(nycmap, extent=’device’)+geom_point(aes(x=lon, y=lat, color = ‘red’, size = log(count)), data=Cam)+
geom_point(aes(x=lon,y=lat, size = 0.2), data= School.Loc)+theme(legend.position=’none’)

Perhaps the speed cameras were deployed to increase the safety of ALL pedestrians. To explore this hypothesis the camera map was overlayed with the density of pedestrian/vehicle collisions in NYC in 2013, the year prior to camera installation. Vehicle/pedestrian collisions occur most frequently in Manhattan, a borough with fewer cameras. This suggests that the largest potential impact would be made by placing the majority, if not all, of the speed cameras in Manhattan, not the outer boroughs. In fact, Brooklyn and Queens have a similar number of pedestrian/vehicle collisions as Manhattan (see below) but Brooklyn and Queens are 3 and 4X larger indicating that if speed cameras reduce pedestrian/vehicle collisions Brooklyn and Queens would require 3 and 4X more cameras than Manhattan to reduce accidents by the same number.

<a href="http://nycdatascience.com/wp-content/uploads/2015/01/Accident2013-e1421268129569.png"><img class="aligncenter  wp-image-4120" src="http://nycdatascience.com/wp-content/uploads/2015/01/Accident2013-1024x796.png" alt="Accident2013" width="594" height="462" /></a>

g = plot(ggmap(nycmap)+geom_point(aes(x=lon, y=lat, size = log(count), color = ‘red’), data= Cam)+

theme(axis.text.x=element_blank(), axis.text.y=element_blank(), axis.title.x=element_blank(),axis.title.y=element_blank(),legend.position=’none’)+

stat_density2d(aes(x=Lon, y=Lat, fill = ..level.., alpha=..level..), geom=’polygon’, data=Accidents.lastyear))+scale_fill_gradient(limits=c(1:60))

After discovering that camera placement is not designed to maximize the safety of either school-aged children or pedestrians a revenue focus was considered. By NYS law,

speed camera placement is only allowed within 1/4 mile from any school building. The placement of a camera outside that radius may indicate city officials are attempting to maximize revenue by issuing more tickets and betting residents will not contest the ticket’s legality. To investigate, the most profitable camera was selected and its

distance to the nearest 3 schools was computed.

<span><span><span><span>filter(Cam, count&gt;10000)</span></span></span></span>
<span>                            <span><span><span style="-style: normal;"><span style="-weight: normal;">Address count       lon      lat</span></span></span></span></span>
<span><span><span>1 Queens Blvd &amp; 58th St, Queens, NY 11528 -73.90751 40.74186</span></span></span>
<span><span style="-variant: normal;"><span><span><span style="letter-spacing: normal;"><span style="-style: normal;"><span style="-weight: normal;">maxtix.map = get_map(location = c(lon = -73.90751, lat = 40.74186), zoom = 15)</span></span></span></span></span></span></span>
<span><span><span><span>ggmap(maxtix.map)+geom_point(aes(x=lon, y = lat, size = log(count), color='red'), data = Cam)+geom_point(aes(x=lon, y =lat, size = 2), data = School.Loc)+
theme(legend.position='none', axis.text.x=element_blank(), axis.text.y=element_blank(), axis.title.x=element_blank(),axis.title.y=element_blank())
</span></span></span></span><span><span><span><span>maxtix.schools = filter(School.Loc, lat &lt; 40.750 &amp; lat &gt;40.730 &amp; lon &lt; -73.895 &amp; lon &gt; -73.922)
maxtix.schools</span></span></span></span>
<span>                              <span><span><span style="-style: normal;"><span style="-weight: normal;">Address       lon      lat</span></span></span></span></span>
<span><span><span>1 54-25 SKILLMAN AVENUE, New York, NY -73.90914 40.74553</span></span></span>
<span><span><span>2       46-02 47 AVENUE, New York, NY -73.91867 40.74084</span></span></span>
<span><span><span>3         67-25 51 ROAD, New York, NY -73.89721 40.73449</span></span></span>
<span><span><span>&gt; <span>mapdist(from = c(lon = -73.90751, lat = 40.74186), to = maxtix.schools$Address)</span></span></span></span>

from                                  to    m    km     miles seconds  minutes      hours
1 46-1 58th Street, Woodside, NY 11377, USA 54-25 SKILLMAN AVENUE, New York, NY  690 0.690 0.4287660     106 1.766667 0.02944444
2 46-1 58th Street, Woodside, NY 11377, USA       46-02 47 AVENUE, New York, NY 1223 1.223 0.7599722     166 2.766667 0.04611111
3 46-1 58th Street, Woodside, NY 11377, USA         67-25 51 ROAD, New York, NY 1792 1.792 1.1135488     235 3.916667 0.06527778

Note the camera’s location, situated on an 8-lane roadway with timed traffic lights just two blocks from the nearest exit on the Brooklyn-Queens Expressway. Visually, the camera location looks close to the school on 55th St & Skillman Ave. However, the computed distance is > 1/10 of a mile outside the legally allowed distance. This is a clear sign of a revenue strategy. After examining the distribution of speed cameras safety was clearly NOT the primary goal of this program. Revenue concerns seemed to have outweighed maximizing pedestrian safety. However, if cameras DO prevent pedestrian/vehicle collision they may still be useful, even though they are deployed in sub-optimal intersections. This is the focus of the next section.

Efficacy of Speed Cameras in Pedestrian/Vehicle Collisions

First we will examine the effect of the speed camera program city-wide and then proceed to analyze the differential effect the speed camera program has had on each borough. The data shows ~10% reduction in traffic accidents city-wide after camera installation in the period from Jan 16 – Jun 20 2014 over the same time period in 2013. Traffic accident data is only available on NYC Open Data as far back as Aug 2012. Pedestrian/vehicle collsions over 5 month intervals were summed from Aug 2012 – Jun 2014 and visualized in a line plot (Dec 2013 was not included due to interval size). The trend is apparent, pedestrian/vehicle collisions were decreasing before the installation of the speed cameras and continue to decline at the same rate after installation. Fatal accidents also declined during the same 5 month period, from 57 in 2013 to 39 in 2014. This is not surprising given the decline in accidents overall.

<a href="http://nycdatascience.com/wp-content/uploads/2015/01/VehicleAccidentsOverTime.png"><img class="aligncenter  wp-image-4122" src="http://nycdatascience.com/wp-content/uploads/2015/01/VehicleAccidentsOverTime-1024x695.png" alt="VehicleAccidentsOverTime" width="592" height="402" /></a>

ggplot(x,aes(x=Date,y=Accidents))+geom_line()+geom_point()+ylab(‘Pedestrian Vehicle Accidents’) +theme_bw()+xlab(”)

 

If speed cameras are associated with reduced pedestrian/vehicle collisions we would expect the frequency of collisions around a camera to decrease much more rapidly than in

areas without cameras. Each camera should “carve out” a spot from the accident density if they significantly reduce the rate of accidents. The pedestrian/vehicle accident

density from 2013 (left) is shown next to the density after camera installation in 2014 (right). The shape of density profile is almost exactly the same, strong evidence

that cameras do not influence the frequency of pedestrian/vehicle collisions.

Camera Impact by Borough

While there isn’t any association of cameras with pedestrian accident frequency city-wide perhaps the boroughs with the most cameras have experienced a reduction in accidents that is “masked” in aggregate by increases in accidents in boroughs with fewer speed cameras. The following script summed the number of cameras in each borough and the number of tickets from all cameras in each borough. I then created a contingency table by merging the data with accident numbers from the Accidents data frame. The contingency table of tabulations is shown below.

camandtixsum = function(x){ y = data.frame() for (i in 1:length(x)){ y[i,1] = length(grep(x[i], Cam$Address)) y[i,2] = sum(Cam$count[grep(x[i], Cam$Address)]) } y = cbind(y, x) return(y) } byBorough = camsum(c(“Brooklyn”,”Staten Island”,”Queens”,”New York”,”Bronx”))
byBorough Borough Cameras Tickets Peds.Killed2014 Peds.Injured2014 Peds.Killed2013 Peds.Injured2013 1 STATEN ISLAND 8 7505 2 112 1 153 2 BRONX 7 5216 3 646 9 728 3 MANHATTAN 8 10479 6 1140 12 1238 4 QUEENS 13 35985 10 866 16 934 5 BROOKLYN 18 25628 15 1405 13 1561

Using these data the impact of the cameras on each borough was visualized. The first plot shows the change in the number of pedestrians killed in vehicle collisions by

borough prior to and after camera installation. The size of each bubble in 2014 represents the number of tickets residents received. The number of cameras and tickets

appear to have no relationship with the number of fatal accidents. The Bronx had the largest %decline in fatal accidents but has the fewest cameras and tickets. Brooklyn

residents received the the second highest number of tickets and have the most cameras of any borough but was the only borough to see its numbers increase in 2014. Pearson’s X-squared test provided additional evidence that cameras are not associated with the rate of fatal collisions (X-squared = 4.4056, df = 4, p = 0.3539).

<span class="GEWYW5YBMDB ace_keyword" style="color: blue;">ggplot(mBorough[mBorough$variable == 'Injured',], aes(x=Borough, y=value))+ylab("Number of Pedestrians Injured")+geom_point(aes(color=factor(Year), size = Tickets))+
geom_line(aes(group=Year, color=Year))+ theme(axis.text.x = element_text(angle = 50))+scale_color_discrete(name='Year')</span>

A similar analysis was conducted with collisions that were not fatal, each borough shows a decline consistent with the 10% overall decline already noted as compared to

2013. However, the accident rates decline similarly for each borough. If the speed cameras did prevent collisions we would expect to see a much more dramatic decline in

Brooklyn and Queens, the two boroughs with the most speed cameras and highest number of tickets issued. Again, Pearson’s X-squared test was not significant (X-squared = 3.1445, df = 4, p = 0.5339).


Conclusion

In the first 6 months of operation the speed camera program has justified the transfer of 4.2 million in wealth from NYC citizens to local government coffers. The program appears to be revenue focused as the camera locations fail to conform to distributions that would optimize pedestrian safety. Additionally, it appears that at least one camera operates outside the boundaries allowed by law further corroborating this conclusion. Furthermore, this study has found no evidence that speed cameras reduce collisions as suggested by the government entities and speed camera vendors. Months after the speed camera program debuted NYC lowered its speed limit by an additional 5MPH. This has also been interpreted as a revenue maximizing strategy which may result to a transfer of wealth in excess of $12M from citizens in 2015.

To leave a comment for the author, please follow the link and comment on their blog: NYC Data Science Academy » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.