Predictive Policing Module

An Example of Average Kerneling and Heat Mapping for use with Predictive Policing

How it works:

  1. Crime data is taken in and cleaned for use. For this example, open source crime data from Cary, North Carolina was used. The data was stripped to crime and latitudinal and longitudinal location.
  2. The crime data is scaled to the drawing canvas and plotted by location.
  3. An averaging kernel algorithm is run. Each kernel is a ‘square’ which measures how many data points are within its boundaries. The kernels overlap (in this case an 80px by 80px kernel is placed every 10px on both the x and y axes to allow for detailed overlap). Each kernel’s display color is scaled based on the number of data points it contains. This display kernel has a low alpha value so that where the kernels overlap, an average crime rate (or color) is produced. This is a heat map.
  4. The user may create another averaging kernel by clicking on the screen. The user’s kernel checks each pixel’s color in the 30px by 30px box the user selects and averages the color (or crime rate) for the entire box. This color is displayed (sans the alpha value) in the box.
  5. The crime rate from within the user’s kernel is calculated and compared to the average crime rate for the entire map (the percent difference from the average). Negative values indicate a crime rate lower than the average crime rate, and positive values indicate a crime rate higher than the average crime rate. If the percent difference is lower than -105%, this means that the user’s kernel’s crime rate is insignificant or that the user’s kernel is out of bounds of Cary, and an error message is displayed.
<iframe src="https://www.openprocessing.org/sketch/644985/embed/?plusEmbedHash=YzBjNTljYzQ2NmUzMTQ2NDczMDk2MTc5Y2RmMWFhMzhjZjc5NzBmNDUwYzQ2ZWVhOWViODIwNjNkOTliZDYwMjBlZTY5ZmYyMDg4NDlkNjQ1YTBhNTg5MTMzZmRlMjE3Yzc2YjE5NzZhNjhmMDMwZWNkMDYyNThhZDQ2MjdkNDdUZ0JaVktUUFp3ZGFuVFN2WkMyZnlGVDc0c3YyOHJ3TGJoOXRlL2FhMHdYaEJzcThZaGMxMHhLQlB1L2Y0RzVLSVBWZU0rUUJsSGRDVjhUOTg4RWQ5Zz09&plusEmbedTitle=true" width="800" height="1185">