Creating a Heatmap using QGIS

From CUOSGwiki
Jump to navigationJump to search

Purpose

The purpose of the tutorial is to provide users with a step by step process of how to create a heatmap on QGIS. This tutorial will contain detailed explanations on how to download and use the QGIS software, how to get open source data and how to use the Heatmap feature in Symbology, make analysis and inferences from the data and how to create a map in QGIS. The tutorial will also cover the limitations of QGIS for making Heatmaps. For the tutorial, we would be making a Toronto Crime Heatmap with Data from the Toronto Police.

Disclaimer: This Tutorial is for Educational Purposes only. The result of the Tutorial shows real crime committed in the city of Toronto. Due to the sensitivity of the data to be used, we would only be making heat maps for Property related crimes.
In accordance with the Municipal Freedom of Information and Protection of Privacy Act, the Toronto Police Service has taken the necessary measures to protect the privacy of individuals involved in the reported occurrences. No personal information related to any of the parties involved in the occurrence will be released as open data. The location of crime occurrences have been deliberately offset to the nearest road intersection node to protect the privacy of parties involved in the occurrence. All location data must be considered as an approximate location of the occurrence and users are advised not to interpret any of these locations as related to a specific address or individual.

Introduction

Heatmaps are one of the best visualization tools for dense point data. Heatmap is an interpolation technique that is useful in determining density of input features. Heatmaps are most commonly used to visualize crime data, traffic incidents, housing density etc. The density is calculated based on the number of points in a location, with larger numbers of clustered points resulting in larger values. Heatmaps allow easy identification of “hotspots” and clustering of points. QGIS has a heatmap renderer that can be used to style a point layer and a Processing algorithm Heatmap (Kernel Density Estimation) that can be used to create a raster from a point layer.

Materials

About QGIS

Quantum GIS, better known and QGIS, is arguably the most powerful and commonly used free open source geographic information system software available. It allows the user to create, edit, visually represent, analyze and publish information. It is available for download on a variety of operating systems from Windows, Mac, Linux and BSD, with recent efforts working towards compatibility with Android. QGIS is licensed under the Creative Commons Attribution-ShareAlike 3.0 license (CC BY-SA).

Download QGIS

This tutorial was originally done with QGIS version 3.10.10 ‘A Coruña’ which was released in November 2019. It is available for download on their Official Website. Download and install that version or a more recent version of QGIS for your operating system in order to follow along with the following step-by-step tutorial.

Data Acquisition

There are numerous resources available to acquire spatial data for use in QGIS including Open Data Catalogues, Scholars GeoPortal, Ontario GeoHub etc.
For this tutorial, we will be acquiring data from the “Toronto Police Service Public Safety Data Portal”. The Toronto Police documents and release Public Safety Data. “The Public Safety Data Portal is intended to improve the understanding of policing, improve transparency and enhance confidence through the creation and use of open data for public safety in Toronto.”
Dataset to be used:

  • Major Crime Indicators (MCI) 2014 - 2019 shapefile. Categories are Assault, Break and Enter, Auto Theft, Robbery and Theft Over (Excludes Sexual Assaults)
  • Toronto Neighbourhood Boundary shapefile. This also contains crime data but we just need the shapefile for its boundaries, to provide context for the MCI data.


Steps in data acquisition:

  1. Go to the MCI page by clicking the link (https://data.torontopolice.on.ca/datasets/mci-2014-to-2019)
  2. Click on Download and under Full Dataset click on Shapefile
  3. Repeat the same process for the Neighbourhood Boundary page by clicking the link (https://data.torontopolice.on.ca/datasets/neighbourhood-crime-rates-boundary-file-)
  4. Extract (Unzip) both folders and save in the working director you will be using.

Tools and Methods

Getting started

For this tutorial we would not be changing the Projection and would be using the source projection.

Import Data

  1. The fastest way to import Data is by going through the Browser Panel on the left of your new project screen and navigating to where you stored the 2 shapefiles. In my case I stored the shapefiles in the Download folder. Drag both shapefile to the layers panel. You would need to transform the Neighbourhood Data to match the Projects Projections. Simply click Ok.
  2. Next we would be adding the basemap that is provided by QGIS. in the browser panel, you should see a directory called “XYZ Tiles”. In there is the “OpenStreetMap”. Drag that down to the Layer panel.


At this point your screen should look like this. You might have to rearrange the layers in this order: MCI layer, Neighbourhood layer and OpenStreetMap layer. Feel free to rename the layers, and change the symbology for easy visualization.

Process

Methodology

Conclusion

Resources