Skip to content

San Francisco Police Department Analytics for the Capital One Software Engineering Summit | Update March 28th: I was invited to participate in the Summit after creating SFPD-Dispatch :)

License

Notifications You must be signed in to change notification settings

theriley106/SFPD-Dispatch

Repository files navigation

SFPD-Dispatch

San Francisco Police Department Analytics for the Capital One Software Engineering Summit

Example Addresses

101 Post Street San Francisco, CA 94108 - Capital One Cafe in Union Square

420 Montgomery Street San Francisco, CA 94104 - Capital One Residential Bank

2603 Camino Ramon San Ramon, CA 94583 - Capital One Residential Bank

999 Van Ness Ave, San Francisco, CA 94109 - The second coolest Tesla showroom in Northern California...

527 5th St, San Francisco, CA 94107, USA - An address in SF that has placed 52 Reports within an 11 day period

In Summary

My project proposed the idea that evenly distributing emergency response headquarters would decrease the response time required for problematic areas of San Francisco. The focus primarily being the areas in which response times are more than 5 times higher than the SFPD average.

Interesting Facts about the Data Set

  • Only 29.07% Of Reports are to unique locations

  • The remaining 70.93% are repeated locations

  • The average SFPD Response Time is 8 minutes and 4.61 seconds

  • Calls placed from the Zipcode 94127 have an average response time of 45 minutes and 19.51 seconds

  • The response time average for the zipcode 94127 is 5.61 times the San Francisco Average...

  • Coincidentally, 94127 has the highest Mean Household Income out of all of the zipcodes in SF ($127,575)

Most Active Police Destinations

  1. (37.77762423892872, -122.39998111124002) - 52 Reports

  2. (37.79267911710725, -122.39685349996866) - 45 Reports

  3. (37.786117211837905, -122.4198542456919) - 44 Reports

  4. (37.78186544733037, -122.41428534642068) - 41 Reports

  5. (37.740332988667284, -122.4664485824384) - 40 Reports

  6. (37.77953108466273, -122.41354254868111) - 38 Reports

  7. (37.78480738867744, -122.41361543826261) - 34 Reports

  8. (37.786409613771546, -122.4080362362708) - 34 Reports

  9. (37.7980449492818, -122.3963670843851) - 34 Reports

  10. (37.777712440431586, -122.41273670742505) - 32 Reports

About the Web App

The web app is hosted using Heroku

The Backend was done using Python's Flask framework, and in an attempt to make everything as modularized as possible almost everything is communicated to the front-end using JSON.

I first converted the CSV into a list of python dictionaries to make it a little bit easier to work with. From there, I created a ton of functions in interactions.py to make it easier to filter data.

For instance, the most used function in interactions.py was the following:

def incidentsNearLatLng(point, radius):
	# Returns a list of instances within radius of a long lat point
	dataset = readDataset()
	# Reads the dataset
	values = copy.copy(dataset)
	# This copies that dataset list so nothing is does to this array
	for var in values:
		# Goes through all values in the dataset
		if not checkInRadius((float(var["latitude"]), float(var["longitude"])), point, radius):
			# Checks to see if the value is within the radius
			dataset.remove(var)
			# Removes the value
	return dataset
	# Returns a list of python dictionaries

And I used something called the Haversine equation to calculate distance between two long/lat points. This allowed me to filter out the data to only show incidents that happened nearby.

The data visualization is broken up into 4 parts:

#1 Primary Map/Visualization

N|Solid

Primary Visualization that allows the user to navigate through a map of San Francisco. Address autocomplete has been implemented using Google's Javascript Map API

N|Solid

The user can input an address in San Francisco and the map will move over to center that address's Long/Lat coordinates

N|Solid

You can click nearby point to learn details about incidents that have happened nearby

#2 Reports by Residential Address/Predictions

N|Solid

After the user clicks "View Full Report" the web app will open another window showing details surrounding that Long/Lat coordinate. Note: The background is a satellite view of the address that was inputted.

N|Solid

This coordinate is NOT a coordinate that's in the Dataset, so it uses nearby instances to make predictions about call priority and response time

N|Solid

The user can input a time and the web app will make a prediction about the type of call and response time

N|Solid

The predictions are made using nearby incident reports

N|Solid

After looking at the incident report, users can either go back to the residental map, view the Github repository, or view the additional data visualizations surrounding the entire dataset

#3 Data Visualizations

N|Solid

Visualization showing average response time for each zip code in San Francisco

N|Solid

Visualization showing Mean Household Income for each zip code in San Francisco

N|Solid

Visualization showing average distance from a fire department for each zip code in San Francisco

N|Solid

Visualization showing frequency of Non-Emergency and Emergency calls to the San Francisco police department

N|Solid

After viewing the Data Visualizations, users can go back to the top of the page and click on the large blue button to open the Heatmap

#4 Heatmap

N|Solid

The Heatmap represents the frequency of calls by location in San Francisco

Additional Data Points

I scraped address information for nearby Fire Departments, Hospitals, and Police Stations (below) to further emphasize the importance of having evenly distributed emergency service headquarters.

I also used the University of Michigan Mean Household Income dataset to look at the correlation between police response time and mean household income.

Fire Departments:

  • 935 Folsom at 5th Street
  • 1340 Powell Street at Broadway
  • 1067 Post Street at Polk Street
  • 449 Mission Rock at 3rd Street
  • 1301 Turk Street at Webster Street
  • 135 Sanchez Street at Henry Street
  • 2300 Folsom Street at 19th Street
  • 36 Bluxome Street at 4th Street
  • 2245 Jerrold Avenue at Upton Street
  • 655 Presidio Avenue at Bush Street
  • 3880 26th Street at Church Street
  • 1145 Stanyan Street at Grattan Street
  • 530 Sansome Street at Washington Street
  • 551 26th Avenue at Geary Boulevard
  • 1000 Ocean Avenue at Phelan Avenue
  • 2251 Greenwich Street at Fillmore Street
  • 1295 Shafter Avenue at Ingalls Street
  • 1935 32nd Avenue at Ortega Street
  • 390 Buckingham Way at Winston Street
  • 285 Olympia Way at Clarendon Avenue
  • 1443 Grove Street at Broderick Street
  • 1290 16th Avenue at Irving Street
  • 1348 45th Avenue at Judah Street
  • 100 Hoffman Avenue at Alvarado Street
  • 3305 3rd Street at Cargo Way
  • 80 Digby Street at Addison Street
  • 1814 Stockton Street at Greenwich Street
  • 299 Vermont Street at 16th Street
  • 441 12th Avenue at Geary Boulevard
  • 194 Park Street at Holly Park Circle
  • 8 Capital Street at Broad Street
  • 499 41st Avenue at Geary Boulevard
  • Pier 22½, The Embarcadero at Harrison Street
  • 109 Oak Street at Franklin Street
  • 798 Wisconsin Street at 22nd Street
  • 2150 California Street at Laguna Street
  • 1091 Portola Drive at Miraloma Drive
  • 2155 18th Avenue at Rivera Street
  • 1325 Leavenworth Street at Jackson Street
  • 2430 San Bruno Avenue at Silver Avenue
  • 720 Moscow Street at France Avenue
  • 1298 Girard Street at Wilde Avenue
  • 800 Avenue I at 10th Street, Treasure Island
  • 1415 Evans Avenue at Mendell Street
  • 218 Lincoln Blvd at Keyes Avenue

Hospitals in San Francisco:

  • 2425 Geary Blvd
  • 2425 Geary Blvd
  • 1600 Divisadero St
  • 1600 Divisadero St
  • 3700 California St
  • 3700 California St
  • 2333 Buchanan St
  • 2333 Buchanan St
  • 450 Stanyan St
  • 450 Stanyan St
  • Castro and Duboce Streets
  • Castro and Duboce Streets
  • 505 Parnassus Avenue
  • 505 Parnassus Avenue
  • 900 Hyde St
  • 900 Hyde St
  • 1001 Potrero Ave
  • 1001 Potrero Ave
  • 3555 Cesar Chavez
  • 3555 Cesar Chavez
  • 845 Jackson St
  • 845 Jackson St
  • 1200 El Camino Real
  • 1200 El Camino Real
  • 350 Hawthorne Ave

About

San Francisco Police Department Analytics for the Capital One Software Engineering Summit | Update March 28th: I was invited to participate in the Summit after creating SFPD-Dispatch :)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published