Visualizing SFPD’s “Operation Safe Schools”

29 September 2009

The San Francisco Police Department has recently launched a new initiative to fight drug dealing near schools. As outlined in this article in the San Francisco Chronicle last Thursday, the police department is targeting drug dealers within 1,000 feet of San Francisco schools who are dealing heroin, crack, or methamphetamine during school hours. These particular drug offenses violate the “Juvenile Drug Trafficking and Schoolyard Act of 1988” and can add two to three years to the offender’s prison sentence.

The following video walks through how quickly we were able to use SpatialKey to filter down over 14,000 crime records from the past 90 days to isolate these exact drug crimes. By the end of this short 5-minute video we produce a list of the schools that have these particular narcotics incidents near them. This is an example of using the powerful proximity filtering in SpatialKey to filter one dataset by buffering around another, as well as filtering by type of crime, day of week, and hour of day.

Data sources

Both the crime data and the school locations were downloaded from San Francisco’s new data warehousing website: datasf.org. The police department provides a feed of the last 90 days of crime incidents as a shapefile. The dataset used in the video was downloaded on September 21, 2009 and includes crime records from June 25, 2009 to September 20, 2009. Additionally, the city’s GIS department provides the files for the locations of all the private and public schools in San Francisco (both as shapes and as points).

How we did it: step-by-step

I’ll walk through a visual explanation of how we filtered down the 14,653 crimes. These steps are the ones you see performed in the video. You can click each screenshot thumbnail on the right to view the full screenshot.

Step 1: Load in the crime data

spatialkey_sfpd_crime_thumb1We imported the shapefile that we downloaded from the SFPD’s website into SpatialKey and opened a new full-screen map template. This initial map shows all 14,653 incidents. The heatmap shows the distribution of crimes in the city. It is very clear that the most crime activity occurs downtown.

Step 2: Buffer around the schools

spatialkey_sfpd_crime_thumb3We then brought in our second dataset, which was the shapes of all the public and private schools in San Francisco. We used the Proximity Filter capabilities of SpatialKey to create a 1,000 foot buffer around each school and only include the crimes within that buffer. You can see the filter in action and how it removed all the crimes that are not near schools. This filtered out approximately 6,000 crimes and brought our total count down to 8,417.

Step 3: Only show drug crimes

spatialkey_sfpd_crime_thumb4Since we were only interested in narcotics crimes, we opened up a pod to show the type of crime (this was a field called “Category” in the data provided by the SFPD). We filtered out all crimes except “Drug/Narcotics,” which left only 1,849 crimes.

Step 4: Filter by day of week and hour of day

spatialkey_sfpd_crime_thumb5Then we filtered by Day of Week to only include crimes occurring Monday through Friday. We also opened up a histogram showing the distribution by hour of day and we selected a range from 7 am to 4 pm. This is an approximation of school hours. Obviously all schools will have slightly different exact hours of operation.

Step 5: Only show heroin/crack/meth

spatialkey_sfpd_crime_thumb6The Juvenile Drug Trafficking and Schoolyard Act is specifically for certain types of drug crimes, so we needed to filter out the other drug crimes that we weren’t interested in. Luckily, the SFPD provides a field in the dataset called “Description” that provides more granular detail about the type of crime, including what type of drug was involved. We filtered out any crimes that did not include the sale of heroin, crack cocaine, and methamphetamine. This brought our total dataset down to 166 crimes.

So in literally under 4 minutes we were able to go from over 14,000 crimes to a very targeted list of 166 and from 243 schools down to a list of 21 that we would want to act on.

Try it for yourself

You can open up the sample report that we created to visualize these crimes. We saved the report with all the filters in place (buffered around schools, during school hours, only certain drug crimes). You can modify these filters if you want to see how the filtering in SpatialKey works. The report is fully interactive, so you can really explore the crime activity in San Francisco.

Notes

This data included crimes during the summer when it is likely that most schools are not in session. The purpose of this example is not to find the exact crimes that occurred during the actual school hours, but instead to find the geographic locations where crimes tend to occur during school hours. The areas we highlighted tend to have drug crimes occur at the right time of day, so we are extrapolating that during the school year this trend would continue.

It is also important to note that this is data of active police activity (ie arrests, citations). This means it is not a comprehensive dataset of where crime occurs. This is data about where the SFPD is arresting people. This is an important distinction to keep in mind. An increase in the number of arrests in a certain area may very well be a very good thing indicating that the police are focusing on certain problematic areas, not necessarily that actual crime in those areas is on the rise.

The video, images, and reports in this post were created with publicly accessible data. We have no association with the San Francisco police department (but we’d love to, so contact us if you’re from the SFPD and want to use SpatialKey).


del.icio.us:Visualizing SFPD's  digg:Visualizing SFPD's  spurl:Visualizing SFPD's  newsvine:Visualizing SFPD's  furl:Visualizing SFPD's  reddit:Visualizing SFPD's  Y!:Visualizing SFPD's

10 Comments

[...] just posted a new example of using SpatialKey to visualize crime in San Francisco. We load in 90 days of crime data from the city, then filter down to only include sales of heroin, [...]

Posted by New SpatialKey Crime Example for San Francisco | Doug McCune on 29 September 2009 @ 11am

[...] learn more about proximity filtering in SpatialKey, see or demonstration of finding drug crimes near schools or proximity filtering in the feature [...]

Posted by Mapping Saturn and GM Dealerships – Service is Still Nearby | SpatialKey blog on 1 October 2009 @ 12am

Hey – this is really cool.

You should come to our Data Camp event which is on November 7th. We are having a Data SF Web App contest.

http://spot.us/pitches/272

Either way – keep up this kind of stuff – it’s awesome!

Posted by Digidave on 1 October 2009 @ 5pm

You missed many of the cocaine, meth, heroin crimes when you selected them in the video.

What you need is a text filter which you can apply to the descriptions. Selecting by hand (like you did) is slow and error-prone.

Posted by Guest on 1 October 2009 @ 5pm

[...] Visualizing SFPD’s “Operation Safe Schools” | SpatialKey blog. [...]

Posted by Opera Husband » Visualizing SFPD’s “Operation Safe Schools” | SpatialKey blog on 6 October 2009 @ 9am

Regarding missing some of the crimes, we actually didn’t miss any of the sales of crack (cocaine base), meth, or heroin. The ones that you see that we didn’t select may have been possession offenses (we were only interested in sales) or cocaine offenses (as opposed to crack).

Additionally, we do have text filters that you can use to type in valid values, although I wouldn’t argue that that would be more accurate than selecting them individually from the list in our example (this would entirely depend on the type and volume of data).

Posted by Doug McCune on 6 October 2009 @ 1pm

[...] company, SpatialKey, has created a visualisation tool that lets residents check for drug offences taking place near schools. The local data service EveryBlock, meanwhile, is [...]

Posted by RSS For Gadgets » San Francisco’s open for data on 15 October 2009 @ 1am

[...] company, SpatialKey, has created a visualisation tool that lets residents check for drug offences taking place near schools. The local data service EveryBlock, meanwhile, is [...]

Posted by San Francisco’s open for data | Pj News| Latest Daily News About World News, Business, Tech and Entertainment on 15 October 2009 @ 2am

[...] Visualizing SFPD’s “Operation Safe Schools” [...]

Posted by Harnessing the power of City data with SpatialKey | SpatialKey blog on 20 October 2009 @ 2pm

[...] item.  One company, SpatialKey, has created a visualisation tool that lets residents check <http://blog.spatialkey.com/2009/09/visualizing-sfpds-operation-safe-schools/> for drug offences taking place near schools. The local data service EveryBlock, meanwhile, is [...]

Posted by FT.com | Westminster Blog | The Steve Hilton Strategy Bulletins on 5 January 2010 @ 7am

Leave a Comment