Exploring Indianapolis crime with R

Being a new resident of Indianapolis Indiana, I’m curious to see where my new apartment stands in relation to crime hot spots (not that it really matters now since I already signed a year lease). I’ve heard of a recent string of car thefts. Basically cars are being stolen in the morning as people leave them running to warm up. Since I dutifully start my girlfriends car every morning, I’m interested to know where these thefts are concentrated. Further, I’m curious to see how criminal hot spots change over time. Are they stationary? Was there an upswing in home burglaries in richer suburbs during the great recession? Perhaps the Indianapolis Police department has changed policing concentrations? Policing one area more heavily could cause a spike in crime incidents. Are hot spots homogeneous across crime types? That is, perhaps certain areas are more susceptible to certain types of crimes? The list of questions is endless.

All criminal incidents are reported dating back to 2007. 2014 isn’t available yet, however I’m told it should be by April. Indianapolis compiles this data set for the FBI, which is broadly called the uniform crime report (UCR). Because the UCR is administered by the federal government I expect many other cities to have similar data available.

The first step is to download and import the data into Rstudio.

There are a few things to take note of here. First, read.fwf is needed to import the txt file since it is fixed width. The column widths are specified by the second argument in read.fwf. Second, some lines of the text file contain the the “#” character. When R sees this in the read, it thinks its seeing a comment which causes an error in read.fwf. Therefore the comment character in read.fwf is changed to $ (any symbol not in the txt file will do).

The next several lines of code convert the UCR NAD83 coordinates to latitude/longitude.

What you need to note here is that epsg needs to be changed depending on what city you’re looking at. Epsg 2965 corresponds to the Indiana east region, which contains Indianapolis.

The final section of code accesses the google API and downloads a map of Indianapolis. Then ggplot is used to plot the crime coordinates on this map. The post at Sharp Sights Lab has a very good discussion of the arguments in these functions.

The crime maps are shown below for 2008, 2009, and 2013. After briefly scanning the three maps I get the feel that crime densities were far higher in 2008 and 2009 than 2013. What caused this? I have a few hypothesis that relate to the great recession that officially started at the end of 2007. First, perhaps people commit more crimes in times of severe economic stress. On the other hand, it could just be that governments are strapped for cash during these periods and thus increase policing. Could just be that crime rates are trending downward more generally. Which of these causes (or any other for that matter) is open for further investigation.