Introduction

This project examines the San Francisco Police Department crime records between January 1st 2009 and July 31st 2015. It visualizes the trends of major crimes and drugs in the city across time and locations.

Methodology

There were 940,668 observations in the original dataset. Duplicates that shared the same incident numbers were removed, leaving 724,426 observations in the data frame. Some of the infrequent crimes among the 39 crime categories were consolidated together, such as forgeries and bad checks, and there are only 26 crime categories in the resulting data frame. 21,910 drug-related crimes were subsetted into a new data frame, and a column for drug type was created to label the drug that was associated with each crime observation.

What days and times are especially dangerous?

Crime distribution is fairly even throughout the week. Majority of the crimes occurred on Friday (112,351 reported incidents), followed by Saturday (107,510 reported incidents) and Wednesday (104,773 reported incidents). Interestingly, the least amount of incidents were reported on Monday (98,825 reported incidents) and Sunday (97,769 incidents). In the Southern, Northern, Central and Mission districts, the number of crimes increased sharply on Friday and Saturday, then declined for rest of the week. Tenderloin is the only district where the crime occurrences steadily increased from Tuesday to Saturday.

Among the high crime categories, larceny and theft tend to occur on Friday and Saturday. On the other hand, the occurrences of assault steadily increased from Thursday to Sunday, while burglary generally occurred more often during the weekdays than the weekends. Drug crimes were most commonly reported on Wednesday and least reported during the weekends, and robberies happened by approximately the same frequency every day.

Generally, most of the crimes happened during the evening and the night. The crimes least frequently occurred in the early morning, especially between 5am and 6am when there were only 6,914 reported incidents. The crime occurrences then increased steadily through the day as they peaked at noon time (43,286 reported incidents) and in the evening between 6pm and 7pm (46,892 reported incidents). The crime frequency then decreased across night time and sharply declined between 12am and 1am.

Larceny and drug crimes exhibit similar sinusoid time-interval patterns as they peaked around 5pm and declined after 6pm. Assault crimes occurred at similar frequency between 12pm and 1am before they decreased sharply in the early morning. Vandalism and vehicle thefts occurred primarily between 7pm and 12am, while burglaries were more common between 8am and 7pm. Robbery is the only category that displays a V-shape pattern as the crime frequency increased through the day and peaked at 10pm, then fell after 2am.

Across the months and years, the number of crimes declined for approximately 2 years from 2009 to 2011, but increased again since 2011. The Southern, Northern and Central districts all experienced significant increase in crime incidents from 2011 to 2014, whereas crime occurrences in the Mission district peaked in 2013 and subsequently declined. Tenderloin is the sole exception where the number of crime incidents generally fell from 2009 to 2014.

Among the high crime categories, larceny and theft crimes exhibit the most prominent increase in occurrences (by approximately 5,000 incidents per year) after 2011. Assault, vandalism and robbery maintained similar crime frequency every year without any notable increase or decrease, whereas drug is the sole crime category that was steadily reduced by half since 2009.

What are the dangerous locations in SF?

The Southern district was the most dangerous San Francisco district, reporting 139,911 crime incidents since January 2009. Mission and Northern districts were also high crime locations, reporting 92,610 incidents and 86,673 incidents respectively. Park and Richmond districts were the safest locations, with only 43,180 and 39,581 reported crime incidents since 2009.

Larceny and vehicle thefts were common crimes across every district, but they occurred less frequently in the Tenderloin district.

The 800 Block of Bryant Street at South of Market (SOMA) was the most dangerous address in San Francisco, with 24,269 crime incidents reported at the area since January 2009. An average of 20.6 crime incidents were reported at each address, and the median number of reported incidents at each address is 7.

## [1] 20.5873
## [1] 7
##                  Address Longitude Latitude totalCrime
## 2 800 Block of BRYANT ST -122.4034 37.77542      24269

The map indicates that most of the locations that reported at least 150 crime incidents were clustered around downtown San Francisco, such as the 1000 Block of Market Street and the 100 Block of Powell Street. In some cases, however, the locations were far from downtown, such as the 100 Block of Persia Avenue and the 5200 Block of Diamond Heights Blvd.

Are certain non-drug crimes more common in certain areas?

Since 2009, larcenies increased frequently in the Central, Northern, Park, Richmond, Southern and Tenderloin districts. Assault crimes had a notable share of incidents in the Bayview, Mission and Tenderloin districts, whereas vandalism was common in the Bayview, Park and Taraval districts. Vehicle thefts were prominent primarily in the Bayview and Ingleside districts.

The 800 Block of Bryant Street is the most common address for larceny, assault, vandalism and robbery incidents. Vehicle thefts happened most frequently at the 400 Block of Stockton Street, while burglaries were most highly reported at the 800 Block of Market Street.

## [1] 800 Block of BRYANT ST
## 17390 Levels: 0 Block of 10TH ST 0 Block of 11TH ST ... ZOE ST / WELSH ST
## [1] 800 Block of BRYANT ST
## 9823 Levels: 0 Block of 10TH AV 0 Block of 10TH ST ... YOSEMITE AV / KEITH ST
## [1] 800 Block of BRYANT ST
## 12074 Levels: 0 Block of 10TH ST 0 Block of 12TH ST ... ZOE ST / FREELON ST
## [1] 400 Block of STOCKTON ST
## 13183 Levels: 0 Block of 11TH ST 0 Block of 12TH ST ... ZOE ST / WELSH ST
## [1] 800 Block of MARKET ST
## 7345 Levels: 0 Block of 10TH ST 0 Block of 12TH AV ... WISCONSIN ST / 26TH ST
## [1] 800 Block of BRYANT ST
## 6830 Levels: 0 Block of 11TH ST 0 Block of 12TH ST ... ZOE ST / WELSH ST

The following map displays the locations of the frequent occurrences for larcenies (red dots), assaults (blue dots), vandalism (green dots), vehicle thefts (cyan dots), burglaries (black dots) and robberies (purple dots). Larcenies and assaults were spreaded in various locations across San Francisco city, whereas robberies were concentrated along Market Street.

Are certain drugs more common in certain areas?

The Bayview, Central, Ingleside, Mission, Southern, Taraval and Tenderloin districts all show consistent decline in drug incidents from 2009 to 2015, in particular reported cocaine incidents. Cocaine-related crimes were prominent in the Bayview, Mission, Northern and Tenderloin districts. On the other hand, marijuana-related crimes mainly happened in the Bayview, Ingleside, Park, Richmond, Southern and Taraval districts. Meth-related crimes happened frequently in the Bayview, Central, Ingleside, Northern, Richmond and Southern districts. Heroin-related crimes were uncommon except for the Central and the Tenderloin districts.

The four major drug crimes all differ in the locations where they were most frequently reported. Most cocaine-related crimes happened at the 2000 Block of Mission Street, while majority marijuana-related crimes occurred at the 300 Block of Laguna Honda Blvd. The meth-related crimes were primarily located at the 800 Block of Bryant Street, and the heroin-related crimes happened mainly at Turk Street and Leavenworth Street.

## [1] 2000 Block of MISSION ST
## 1274 Levels: 0 Block of 12TH ST ... YORK ST / 24TH ST
## [1] 300 Block of LAGUNAHONDA BL
## 1922 Levels: 0 Block of 12TH ST 0 Block of 14TH ST ... WOOLSEY ST / SOMERSET ST
## [1] 800 Block of BRYANT ST
## 1509 Levels: 0 Block of 12TH ST 0 Block of 1ST ST ... YOSEMITE AV / HAWES ST
## [1] TURK ST / LEAVENWORTH ST
## 511 Levels: 0 Block of 5TH ST 0 Block of 6TH ST ... WILLOW ST / VANNESS AV

The following map displays the frequent locations for cocaine (red dots), marijuana (blue dots), meth (green dots) and heroin (yellow dots). Marijuana had the largest spatial footprint, whereas meth and heroin were mainly concentrated around downtown San Francisco.

Resource:

The San Francisco Police Department crime data set is available here.