Difference between revisions of "Analyzing Crime Data in Ottawa using QGIS"
(113 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
==Introduction== |
==Introduction== |
||
− | The main purpose of this tutorial |
+ | The main purpose of this tutorial is to identify trends in crime in the Ottawa region using open source software. QGIS is the software that will be used for this tutorial. QGIS version 3.14 "Pi" can be downloaded here: (https://www.qgis.org/en/site/forusers/download.html). The data includes many different types of crimes that occurred in Ottawa from 2005 to 2013. The sub regions include: Orleans, Innes, Barrhaven, Kanata North, West-Carleton March, Stittsville-Kanata West, Bay, College, Knoxdale-Merivale, Gloucester-Southgate, Beacon Hill-Cyrville, Rideau-Vanier, Rideau-Rockcliffe, Somerset, Kitchissippi River, Capital, Alta Vista, Cumberland, Osgoode, Rideau-Goulbourn, Gloucester-South Nepean and Kanata South. Some examples of the crimes in the data set are: Total Criminal Code of Canada (CCC) including Traffic, Total Criminal Code of Canada (CCC) excluding Traffic, Crimes against Person, Total number of Homicides, Total Number of Attempted Murders, Total Number of Robberies and Total Number of Assaults (including Sexual Assaults), Total Number of Other Sexual Offences, Number of Abductions, Total Number of Uttering Threats or Intimidation Offences and Total Number of Other Crimes. |
==Where to get the data?== |
==Where to get the data?== |
||
− | Based on the |
+ | Based on the statistics that the Ottawa Police Service have provided, the MADGIC librarians at Carleton University created the shapefiles and they are available for download from the MacOdrum Library website. Considering it is an open source dataset, no login information is required. |
+ | |||
− | Retrieved from: http://madgic.library.carleton.ca/deposit/GIS/Crime_Statistics.zip |
||
+ | The shapefiles are available for download at this link: http://madgic.library.carleton.ca/deposit/GIS/Crime_Statistics.zip |
||
[[File:wheretoget.png|700px]] |
[[File:wheretoget.png|700px]] |
||
− | ==Loading the Dataset into |
+ | ==Loading the Dataset into QGIS== |
+ | The first step to analyzing the data is adding it into QGIS. |
||
− | First step was to select Add Vector Layer symbol. Second step was to use Browse function to locate the data. Finally all shp files were selected from the Crime Wards Shp folder and loaded to the QGIS. |
||
+ | To do so, select the Add Vector Layer symbol. In QGIS 3.14, the Add Vector Layer button is accessible by clicking the Layer dropdown on the top toolbar. From there, navigate to Add Layer and Add Vector Layer. Adding vector layers can also be done by pressing Ctrl+Shift+V on a Windows computer or a Linux machine. Locate the folder where all of the (.shp) files were extracted. You can select to filter by ESRI Shapefile in the bottom right corner to make it easier as there are other types of files in the dataset that were downloaded. |
||
+ | |||
+ | |||
+ | [[File:Add vector layer QGIS.png]] |
||
+ | |||
+ | [[File:Shapefile identify.png|thumb|center|The dropdown to filter for ESRI shapefiles only. This dropdown can help during instances where datasets contain dozens of other types of files. ]] |
||
+ | |||
+ | ==Transforming the Coordinate System== |
||
+ | When using GIS software, using the correct coordinate reference system is detrimental in terms of properly analyzing spatial data. Ensuring that all data frames have the same projection allows all of the data frames to align properly. |
||
+ | To start the analysis, we will transform the coordinate system to WGS 1984 UTM zone 18N, which is the UTM zone for Ottawa. |
||
+ | |||
+ | [[File:Wrong coordinate system.png|700px]] |
||
+ | |||
+ | This is how the shapefiles look after importing them into QGIS. The City of Ottawa appears to be warped. To change this, hover to Project>Properties (as a shortcut on Windows or Linux machines, Ctrl+Shift+P also brings you to Project Properties). |
||
+ | |||
+ | [[File:Snip 4 , changing coordinates.png|700px]] |
||
+ | |||
+ | Under the CRS frame, you can search for any coordinate reference system under the Filter box. To find the coordinate system we are working with easier, search for "UTM zone 18N". On the map in the bottom right, QGIS will highlight where the UTM zone is assigned to. In this case, UTM zone 18N spans over the City of Ottawa. |
||
+ | |||
+ | [[File:Snip 5, correct coordinates.png|700px]] |
||
+ | After the layer coordinates have been transformed, the map appears to be less warped. Ensure that all of the layers have the same coordinate system. Repeat this step for all of the crime data layers that were imported. |
||
− | [[File:loading.png|700px]] |
||
+ | [[File:UTM map of the world.png|thumb|center|UTM map of the world. Photo source: https://www.maptools.com/tutorials/grid_zone_details]] |
||
− | ==Layer Properties== |
||
− | Layers Properties can be opened by right clicking any of the layers and selecting properties. Right clicking the Layer Properties would bring up the following screen.Layer Properties include: General Settings, Style, Labels, Fields, Rendering, Display, Actions, Joints, Diagrams and Metadata. |
||
+ | ==Introduction to Layer Properties== |
||
− | [[File:layerpro.png|700px]] |
||
+ | Layer Properties can be opened by right clicking any of the layers and clicking Properties. This opens the Layer Properties window. From here, several aspects of the layer can be edited. Some examples include layer title, symbology, labels and so on. |
||
===General Settings=== |
===General Settings=== |
||
− | [[File: |
+ | [[File:Screenshot, Source.png|700px]] |
− | Under |
+ | Under Source: |
+ | *Layer name can be modified and changed to anything. Changing layer names is key to be able to identify different layers. In the case that the data layers came without clear labels, labelling them by year is crucial in order to easily identify each data set. |
||
− | *Layer name can be modified and displayed as something else |
||
+ | *Data source encoding can be changed (System, Windows, and Macintosh for example) |
||
− | *Layer source can be modified |
||
− | *Data source encoding can be changed (System, Windows, and Macintosh etc.) |
||
*Coordinate Reference System can be changed |
*Coordinate Reference System can be changed |
||
*Scale dependency can be turned on to restrict the minimum and the maximum scale |
*Scale dependency can be turned on to restrict the minimum and the maximum scale |
||
===Labels=== |
===Labels=== |
||
− | [[File: |
+ | [[File:Layer properties.png|700px]] |
− | Labels can be |
+ | Labels can be used in any vector layer. Some label settings include: |
− | *Text (to modify the size, font style, transparency, color and style of |
+ | *Text (Able to modify the size, font style, transparency, color and style of text) |
− | *Formatting (to modify the line height and alignment) |
+ | *Formatting (Able to modify the line height and alignment) |
*Buffer |
*Buffer |
||
− | *Background (to modify the background settings) |
+ | *Background (Able to modify the background settings) |
+ | *Shadow (Use this setting to add depth to labels by adding shadows) |
||
− | *Shadow |
||
− | *Placement (to modify the placement |
+ | *Placement (Use this setting to modify the placement of the labels, including distance from centroid) |
− | *Rendering (to perform scale based visibility and pixel based visibility |
+ | *Rendering (Able to perform scale based visibility and pixel based visibility) |
===Fields=== |
===Fields=== |
||
− | [[File:fields.png|700px]] |
||
+ | Within the Field Properties tab, you can edit the field data as well as create new fields using the Field Calculator. Any new fields you create will appear at the bottom of the field list. |
||
− | Using the field properties fields can be edited, and new fields can be created using field calculator. New output-field name, output-field type, output-field width and output-field precision should be determined when creating a new column. As an example new field called “area” is created, which is under geometry function called “$area”. It is going to be used to determine the population density because the data does not have that information, it only has total population. (Area/ 1000000 was used to get the area km^2 value) |
||
+ | To create a new column in the attribute table, open Fields under Properties and click the Area Calculator button. Here we will start to calculate the population density of crimes for years 2016, 2013 and 2010. The data downloaded does not contain the area km^2 value that is needed to calculate population density of crimes. Therefore, it needs to be created. Under Field Calculator, the first step is to calculate area km^2. In the Expression box, enter the calculation $area/1000000. Enter an output field name (In the example, "area km ^" was used), and click OK. When doing calculations in the Field Calculator, if an expression is invalid, it will state "Expression is invalid" in red. |
||
− | [[File:creatingarea.png|700px]] |
||
+ | |||
+ | |||
+ | [[File:Newnewvariable.png|700px]] |
||
====Creating the population density field==== |
====Creating the population density field==== |
||
− | The total population divided by the |
+ | The total population divided by the area will result in the population density. We will calculate population density for layers 2010, 2013 and 2016. |
+ | To calculate population density, insert the function (pop2016/"area km2") into the calculator. Area km2 is the attribute that was created in the previous step. The area km^2 attribute that was just created can also be found under the Fields and Values tab. |
||
− | [[File:popden.png|700px]] |
||
+ | |||
+ | [[File:Pop den description.png|700px]] |
||
===Rendering=== |
===Rendering=== |
||
− | Rendering can be |
+ | Rendering can be used to simplify the geometry. Under the Rendering tab, simplification threshold and scale can be customized to enhance the rendering process. |
− | [[File: |
+ | [[File:NewRendering.png|700px]] |
===Additional Settings under Layer Properties=== |
===Additional Settings under Layer Properties=== |
||
− | Additionally |
+ | Additionally, under Layer Properties, other tools such as Legend, Actions, Joins, Display and Variables can be accessed. |
− | |||
− | [[File:additionals.png|700px]] |
||
+ | [[File:Layer properties 2.png|700px]] |
||
===Using Style and Diagram Functions under Layer Properties=== |
===Using Style and Diagram Functions under Layer Properties=== |
||
Line 69: | Line 92: | ||
=====Single Symbol===== |
=====Single Symbol===== |
||
− | Single Symbol Function is useful for |
+ | Single Symbol Function is useful for showring the features without any sort of categorization. An example below demonstrates a map of Ottawa without any sort of categorization. |
[[File:mapottsingle.png|700px]] |
[[File:mapottsingle.png|700px]] |
||
=====Categorized Style===== |
=====Categorized Style===== |
||
− | Categorized style is useful for showing simple categorizations. As an example below: Map of Ottawa showing the wards in different colors. |
||
+ | Categorized style is useful for demonstrating areas in the City of Ottawa. To symbolize the map this way, right click any layer (in this case, the crime wards in 2010 is used), and go to Symbology. |
||
− | [[File:catott.png|700px]] |
||
+ | |||
+ | [[File:Categorized.png|700px]] |
||
+ | |||
+ | Select ward_Name as the value, and select Classify on the bottom left corner. |
||
+ | |||
+ | [[File:Map of city 1.png|700px]] |
||
+ | |||
+ | Under the Labels tab in Layer Properties, click Single Labels and select ward_Name for the value. This will generate labels for each ward in the City of Ottawa. |
||
=====Graduated Symbols===== |
=====Graduated Symbols===== |
||
− | Graduated Symbols are useful for displaying the features based on their numerical values. First style needs to be selected as Graduated |
+ | Graduated Symbols are useful for displaying the features based on their numerical values. First, the style of symbology needs to be selected as Graduated under the Symbology tab. The value that will be classified is the Population Density attribute that was created earlier. Select "pop_den" from the Value dropdown. |
− | [[File:graduate.png|700px]] |
||
+ | [[File:Pop den demonstration.png|700px]] |
||
− | [[File: |
+ | [[File:Pop den map.png|700px]] |
− | + | Map demonstrating population density in the City of Ottawa in 2010, using graduated symbols and labels. |
|
− | [[File: |
+ | [[File:Robberies in Ottawa.png|700px]] |
− | + | Map demonstrating total number of robberies by ward in the City of Ottawa in 2010, using graduated symbols and labels. |
|
+ | |||
− | Quick Analysis: Even though Somerset ward has one of the highest population densities with Rideau Vanier ward. The total number of robberies are lower at Somerset ward compare to Rideau Vanier ward. Capital ward has one of the highest population densities in the city coming after Somerset ward and Rideau Vanier ward, however Capital ward has one of the lowest total number of robberies in Ottawa. |
||
+ | Using the Graduated Symbols function, it is apparent from the map that there is a higher population density in the downtown core of Ottawa. From observing the second map, there were more robberies in the downtown core in 2010 as well. |
||
====Diagrams==== |
====Diagrams==== |
||
+ | Diagrams are useful for showing multiple features on a single layer. |
||
− | Diagrams are useful for showing multiple features on a single layer. First display diagram should be toggled on. Then diagram type should be selected (Pie Chart, Histogram or Text diagram). After that priority level was set to medium. Furthermore size and positions can be rearranged under the size and the position tabs. Additionally minimum size of the diagram was set to 5 to make all the diagrams visible. Then under Position tab placement was selected to free. And finally attributes were assigned, in this case total number of robberies, total number of abductions and total number of break ins were assigned as an attribute. |
||
+ | To access diagrams, open Layer Properties and navigate to Diagrams. On the dropdown in Diagrams, select Pie Chart. Below, all of the attributes in the selected layer (in this case crime wards in 2010) will be displayed. For the purpose of this tutorial, total number of robberies, abductions and assaults are used as attributes in the pie chart. |
||
− | [[File: |
+ | [[File:Pie chart attribute.png|600px]] |
+ | At first, the pie charts can be too large and cover most of the map, similar to this: |
||
+ | [[File:Big pie chart.png|600px]] |
||
+ | To counter this, open Diagrams again and navigate to Size. There, the pie chart (or other diagrams) size can be adjusted. For the sake of the tutorial, size 7 will be used. |
||
− | Maps below are showing the difference between the Pie Chart diagram type and text diagram type for the same data. |
||
− | [[File: |
+ | [[File:Size in QGIS.png|600px]] |
+ | [[File:New adjusted pie chart.png|600px]] |
||
− | Figure is showing the Pie chart diagram type |
||
+ | This is how the map looks when the size of the pie charts were reduced. |
||
− | [[File:textdia.png|700px]] |
||
+ | ==Cartographic Design and Crime Data in Ottawa== |
||
− | Figure is showing the text diagram type |
||
+ | While QGIS is a powerful tool that allows users to visually analyze data and compare them on maps, sometimes a final product is required. There are many cartographic aspects that are behind maps such as colour, scale, legend, north arrow, labelling and title. |
||
+ | Using these cartographic aspects, we can make a map displaying any variable in the attribute table. |
||
+ | For this tutorial, the crime wards data from 2016 will be used. The variable that is used is asslt_num, total number of assaults in Ottawa in 2016. However, any variable in the attribute table can be used. |
||
+ | Similar to earlier in the tutorial, open Layer Properties and navigate to Symbology. There, select Graduated. |
||
+ | |||
+ | [[File:Cartography aspect.png|600px]] |
||
+ | |||
+ | Graduated menu where users can adjust color ramp, class and variable. |
||
+ | |||
+ | Next, to create a final product, navigate to Project>New Print Layout (or click Ctrl+P on Windows and Linux machines). It will bring up a separate menu. To add the map created in the main menu of QGIS, navigate to Add item>Add Map. Highlight the work area and the map will appear. |
||
+ | |||
+ | It's possible that the map will appear small on the project layout. To adjust the size of the map, the scale needs to be adjusted. The scale used for this project is 500000. |
||
+ | |||
+ | [[File:Ottawa total assaults.png|600px]] |
||
+ | |||
+ | The scale is located on the right side bar under Main Properties. |
||
+ | |||
+ | Next, a legend is required. Navigate to Add Item> Add Legend. Similar to importing the map, drag the cursor along the project working area. |
||
+ | |||
+ | [[File:QGIS working area.png|600px]] |
||
+ | |||
+ | Because there are so many layers present in QGIS, the legend appears with a lot of attributes, many that are not relevant to the project being worked on. To remove these from the legend, navigate to the right toolbar and uncheck "Auto update". From there, anything not wanted on the legend is able to be deleted using the delete button. |
||
+ | |||
+ | [[File:Legend items.png|600px]] |
||
+ | |||
+ | Delete anything that doesn't belong to the crime wards in 2016 layer. |
||
+ | |||
+ | [[File:New legend.png|600px]] |
||
+ | |||
+ | The legend will now look like this. |
||
+ | |||
+ | Using the Main Properties tab, add a title to the legend. "Legend" just works as well. The crime ward layer was renamed to "Number of Assaults" so it shows on the legend. |
||
+ | |||
+ | [[File:Number of assaults.png|600px]] |
||
+ | |||
+ | Using Add Item again, select Scale Bar. Drag the cursor underneath the map of Ottawa to add a scale bar. Repeat this again to add a North Arrow. |
||
+ | |||
+ | Don't forget about the labels. The labels can be adjusted in the 2016 crime wards Layer Properties under Labels. I added a buffer, shadow and aligned my labels offset from centroid. |
||
+ | |||
+ | [[File:So far map.png|700px]] |
||
+ | |||
+ | Finally, add a title and source the data. "Number of Crimes in the City of Ottawa in 2016" works. Text can be added by using the Add Label button underneath Add Item. Adjusting the size and text is all under Appearance on the right hand tool bar. |
||
+ | |||
+ | Source the data set as well. (Remember, it was retrieved from the MADGIC desk at Carleton University). |
||
+ | |||
+ | [[File:Assaultsmap.png|700px]] |
||
+ | |||
+ | This is the final product, complete with a title, source, scale bar, legend, north arrow and labels. |
||
==Additional Statistics== |
==Additional Statistics== |
||
− | Additional statistics can be obtained under Vector |
+ | Additional statistics can be obtained under Vector>Analysis Tools>Basic Statistics for Fields.. |
+ | Select input layer and desired attribute. |
||
+ | |||
+ | [[File:Break ins stats.png|600px]] |
||
+ | |||
+ | In this case, we will analyze the number of break ins in 2016. |
||
+ | |||
+ | [[File:Stats breakdown.png|600px]] |
||
+ | The Basic Statistics tool then displays the statistics of the field demonstrating number of break ins in 2016. |
||
− | [[File:additionalstats.png|700px]] |
||
+ | The Basic Statistics tool is handy for analyzing geospatial data. GIS software is not just useful for creating maps. |
||
==Different Scenarios == |
==Different Scenarios == |
||
− | ====Scenario 1 (Comparing |
+ | ====Scenario 1 (Comparing Impaired Driving from 2010, 2013 and 2016)==== |
+ | [[File:Impaired driving 2010.png|700px]] |
||
+ | Impaired driving data from 2010. |
||
− | [[File:Sa.png|700px]] |
||
+ | [[File:Impaired driving 2013.png|700px]] |
||
− | Quick Analysis: The number of impaired driving occurrences in suburbs (Kanata, Cumberland) from 2005 to 2010 has become lower. However the number of impaired driving occurrences in east end from 2010 to 2013 has become significantly higher, and the number of impaired driving occurrences increased dramatically in College ward in from 2005 and 2010 to 2013. |
||
+ | Impaired driving data from 2013. |
||
+ | [[File:Impaired driving 2016.png|700px]] |
||
− | ====Scenario 2 (Analyzing the total number of violent crimes, the total number of assaults and the number of traffic offences from 2010 data using Diagrams )==== |
||
+ | Impaired driving data from 2016. |
||
− | [[File:sce2.png|700px]] |
||
+ | A quick analysis of the maps demonstrates that impaired driving has affected all areas of Ottawa, but consecutively in each year, there were a lot of impaired driving incidents in the downtown core near Rideau-Vanier, conveniently where a lot of bars and clubs are located. |
||
− | The diagrams are showing that the western and the southern areas of Ottawa have less number of violent crimes, assaults and traffic offences even though they have relatively similar population density. Somerset ward has the highest population density as well as the highest number of violent crimes, assaults and traffic offences. |
||
+ | |||
+ | ====Scenario 2 (Observing trends through mapping: Analyzing break ins in the City of Ottawa in 2010, 2013 and 2016)==== |
||
+ | |||
+ | [[File:Break ins, 2010.png|700px]] |
||
+ | |||
+ | Map demonstrating break ins in the year 2010. |
||
+ | |||
+ | [[File:Breakin2013.png|700px]] |
||
+ | |||
+ | Map demonstrating break ins in the year 2013. |
||
+ | |||
+ | [[File:Break ins 2016.png|700px]] |
||
+ | |||
+ | Map demonstrating break ins in the year 2016. |
||
+ | |||
+ | After observing all three maps, there was a significant decrease in break ins from the years 2010-2016 throughout the whole city. Maps like these can support programs by demonstrating trends in criminal activity, and to observe what programs work, and which ones don't work. |
||
==Conclusion== |
==Conclusion== |
||
+ | |||
− | Conclusively this tutorial highlights that QGIS was a powerful open source GIS software for analyzing the crime trends in Ottawa from 2005 to 2013. There are many other different crimes to analyze from, only limited number of crimes were highlighted in this tutorial. The QGIS software can be downloaded from the website highlighted above and the crime data can be downloaded from the MacOdrum Library website mentioned above for further analysis. |
||
+ | In conclusion, this tutorial aims to highlight the many aspects of data analyzation that can be performed using GIS software, such as QGIS. It also aims to briefly overview cartographic elements and inform how to create a final product, and how these final products assist in visually analyzing trends in data. |
||
+ | |||
+ | ==Reference List== |
||
+ | |||
+ | *Ottawa Police Service Crime Data. (2017). |
||
+ | The data is gathered from the Carleton University MADGIC Desk’s website. |
||
+ | |||
+ | Ottawa Police Service Crime Data retrieved from: |
||
+ | http://madgic.library.carleton.ca/deposit/GIS/Crime_Statistics.zip |
||
+ | |||
+ | *QGIS 3.14 ("Pi") Software, which was downloaded from: |
||
+ | https://www.qgis.org/en/site/forusers/download.html |
Latest revision as of 17:59, 6 October 2020
Contents
- 1 Introduction
- 2 Where to get the data?
- 3 Loading the Dataset into QGIS
- 4 Transforming the Coordinate System
- 5 Introduction to Layer Properties
- 6 Cartographic Design and Crime Data in Ottawa
- 7 Additional Statistics
- 8 Different Scenarios
- 9 Conclusion
- 10 Reference List
Introduction
The main purpose of this tutorial is to identify trends in crime in the Ottawa region using open source software. QGIS is the software that will be used for this tutorial. QGIS version 3.14 "Pi" can be downloaded here: (https://www.qgis.org/en/site/forusers/download.html). The data includes many different types of crimes that occurred in Ottawa from 2005 to 2013. The sub regions include: Orleans, Innes, Barrhaven, Kanata North, West-Carleton March, Stittsville-Kanata West, Bay, College, Knoxdale-Merivale, Gloucester-Southgate, Beacon Hill-Cyrville, Rideau-Vanier, Rideau-Rockcliffe, Somerset, Kitchissippi River, Capital, Alta Vista, Cumberland, Osgoode, Rideau-Goulbourn, Gloucester-South Nepean and Kanata South. Some examples of the crimes in the data set are: Total Criminal Code of Canada (CCC) including Traffic, Total Criminal Code of Canada (CCC) excluding Traffic, Crimes against Person, Total number of Homicides, Total Number of Attempted Murders, Total Number of Robberies and Total Number of Assaults (including Sexual Assaults), Total Number of Other Sexual Offences, Number of Abductions, Total Number of Uttering Threats or Intimidation Offences and Total Number of Other Crimes.
Where to get the data?
Based on the statistics that the Ottawa Police Service have provided, the MADGIC librarians at Carleton University created the shapefiles and they are available for download from the MacOdrum Library website. Considering it is an open source dataset, no login information is required.
The shapefiles are available for download at this link: http://madgic.library.carleton.ca/deposit/GIS/Crime_Statistics.zip
Loading the Dataset into QGIS
The first step to analyzing the data is adding it into QGIS. To do so, select the Add Vector Layer symbol. In QGIS 3.14, the Add Vector Layer button is accessible by clicking the Layer dropdown on the top toolbar. From there, navigate to Add Layer and Add Vector Layer. Adding vector layers can also be done by pressing Ctrl+Shift+V on a Windows computer or a Linux machine. Locate the folder where all of the (.shp) files were extracted. You can select to filter by ESRI Shapefile in the bottom right corner to make it easier as there are other types of files in the dataset that were downloaded.
Transforming the Coordinate System
When using GIS software, using the correct coordinate reference system is detrimental in terms of properly analyzing spatial data. Ensuring that all data frames have the same projection allows all of the data frames to align properly. To start the analysis, we will transform the coordinate system to WGS 1984 UTM zone 18N, which is the UTM zone for Ottawa.
This is how the shapefiles look after importing them into QGIS. The City of Ottawa appears to be warped. To change this, hover to Project>Properties (as a shortcut on Windows or Linux machines, Ctrl+Shift+P also brings you to Project Properties).
Under the CRS frame, you can search for any coordinate reference system under the Filter box. To find the coordinate system we are working with easier, search for "UTM zone 18N". On the map in the bottom right, QGIS will highlight where the UTM zone is assigned to. In this case, UTM zone 18N spans over the City of Ottawa.
After the layer coordinates have been transformed, the map appears to be less warped. Ensure that all of the layers have the same coordinate system. Repeat this step for all of the crime data layers that were imported.
Introduction to Layer Properties
Layer Properties can be opened by right clicking any of the layers and clicking Properties. This opens the Layer Properties window. From here, several aspects of the layer can be edited. Some examples include layer title, symbology, labels and so on.
General Settings
Under Source:
- Layer name can be modified and changed to anything. Changing layer names is key to be able to identify different layers. In the case that the data layers came without clear labels, labelling them by year is crucial in order to easily identify each data set.
- Data source encoding can be changed (System, Windows, and Macintosh for example)
- Coordinate Reference System can be changed
- Scale dependency can be turned on to restrict the minimum and the maximum scale
Labels
Labels can be used in any vector layer. Some label settings include:
- Text (Able to modify the size, font style, transparency, color and style of text)
- Formatting (Able to modify the line height and alignment)
- Buffer
- Background (Able to modify the background settings)
- Shadow (Use this setting to add depth to labels by adding shadows)
- Placement (Use this setting to modify the placement of the labels, including distance from centroid)
- Rendering (Able to perform scale based visibility and pixel based visibility)
Fields
Within the Field Properties tab, you can edit the field data as well as create new fields using the Field Calculator. Any new fields you create will appear at the bottom of the field list.
To create a new column in the attribute table, open Fields under Properties and click the Area Calculator button. Here we will start to calculate the population density of crimes for years 2016, 2013 and 2010. The data downloaded does not contain the area km^2 value that is needed to calculate population density of crimes. Therefore, it needs to be created. Under Field Calculator, the first step is to calculate area km^2. In the Expression box, enter the calculation $area/1000000. Enter an output field name (In the example, "area km ^" was used), and click OK. When doing calculations in the Field Calculator, if an expression is invalid, it will state "Expression is invalid" in red.
Creating the population density field
The total population divided by the area will result in the population density. We will calculate population density for layers 2010, 2013 and 2016.
To calculate population density, insert the function (pop2016/"area km2") into the calculator. Area km2 is the attribute that was created in the previous step. The area km^2 attribute that was just created can also be found under the Fields and Values tab.
Rendering
Rendering can be used to simplify the geometry. Under the Rendering tab, simplification threshold and scale can be customized to enhance the rendering process.
Additional Settings under Layer Properties
Additionally, under Layer Properties, other tools such as Legend, Actions, Joins, Display and Variables can be accessed.
Using Style and Diagram Functions under Layer Properties
Style Function
Under Style there is a dropdown menu, which the Single Symbol, Categorized, Graduate, Rule Based, Point Displacement, Inverted Polygons and Heat Map can be selected. For the purpose of this tutorial I am mainly going to focus on the Graduate Style.
Single Symbol
Single Symbol Function is useful for showring the features without any sort of categorization. An example below demonstrates a map of Ottawa without any sort of categorization.
Categorized Style
Categorized style is useful for demonstrating areas in the City of Ottawa. To symbolize the map this way, right click any layer (in this case, the crime wards in 2010 is used), and go to Symbology.
Select ward_Name as the value, and select Classify on the bottom left corner.
Under the Labels tab in Layer Properties, click Single Labels and select ward_Name for the value. This will generate labels for each ward in the City of Ottawa.
Graduated Symbols
Graduated Symbols are useful for displaying the features based on their numerical values. First, the style of symbology needs to be selected as Graduated under the Symbology tab. The value that will be classified is the Population Density attribute that was created earlier. Select "pop_den" from the Value dropdown.
Map demonstrating population density in the City of Ottawa in 2010, using graduated symbols and labels.
Map demonstrating total number of robberies by ward in the City of Ottawa in 2010, using graduated symbols and labels.
Using the Graduated Symbols function, it is apparent from the map that there is a higher population density in the downtown core of Ottawa. From observing the second map, there were more robberies in the downtown core in 2010 as well.
Diagrams
Diagrams are useful for showing multiple features on a single layer. To access diagrams, open Layer Properties and navigate to Diagrams. On the dropdown in Diagrams, select Pie Chart. Below, all of the attributes in the selected layer (in this case crime wards in 2010) will be displayed. For the purpose of this tutorial, total number of robberies, abductions and assaults are used as attributes in the pie chart.
At first, the pie charts can be too large and cover most of the map, similar to this:
To counter this, open Diagrams again and navigate to Size. There, the pie chart (or other diagrams) size can be adjusted. For the sake of the tutorial, size 7 will be used.
This is how the map looks when the size of the pie charts were reduced.
Cartographic Design and Crime Data in Ottawa
While QGIS is a powerful tool that allows users to visually analyze data and compare them on maps, sometimes a final product is required. There are many cartographic aspects that are behind maps such as colour, scale, legend, north arrow, labelling and title. Using these cartographic aspects, we can make a map displaying any variable in the attribute table. For this tutorial, the crime wards data from 2016 will be used. The variable that is used is asslt_num, total number of assaults in Ottawa in 2016. However, any variable in the attribute table can be used. Similar to earlier in the tutorial, open Layer Properties and navigate to Symbology. There, select Graduated.
Graduated menu where users can adjust color ramp, class and variable.
Next, to create a final product, navigate to Project>New Print Layout (or click Ctrl+P on Windows and Linux machines). It will bring up a separate menu. To add the map created in the main menu of QGIS, navigate to Add item>Add Map. Highlight the work area and the map will appear.
It's possible that the map will appear small on the project layout. To adjust the size of the map, the scale needs to be adjusted. The scale used for this project is 500000.
The scale is located on the right side bar under Main Properties.
Next, a legend is required. Navigate to Add Item> Add Legend. Similar to importing the map, drag the cursor along the project working area.
Because there are so many layers present in QGIS, the legend appears with a lot of attributes, many that are not relevant to the project being worked on. To remove these from the legend, navigate to the right toolbar and uncheck "Auto update". From there, anything not wanted on the legend is able to be deleted using the delete button.
Delete anything that doesn't belong to the crime wards in 2016 layer.
The legend will now look like this.
Using the Main Properties tab, add a title to the legend. "Legend" just works as well. The crime ward layer was renamed to "Number of Assaults" so it shows on the legend.
Using Add Item again, select Scale Bar. Drag the cursor underneath the map of Ottawa to add a scale bar. Repeat this again to add a North Arrow.
Don't forget about the labels. The labels can be adjusted in the 2016 crime wards Layer Properties under Labels. I added a buffer, shadow and aligned my labels offset from centroid.
Finally, add a title and source the data. "Number of Crimes in the City of Ottawa in 2016" works. Text can be added by using the Add Label button underneath Add Item. Adjusting the size and text is all under Appearance on the right hand tool bar.
Source the data set as well. (Remember, it was retrieved from the MADGIC desk at Carleton University).
This is the final product, complete with a title, source, scale bar, legend, north arrow and labels.
Additional Statistics
Additional statistics can be obtained under Vector>Analysis Tools>Basic Statistics for Fields.. Select input layer and desired attribute.
In this case, we will analyze the number of break ins in 2016.
The Basic Statistics tool then displays the statistics of the field demonstrating number of break ins in 2016.
The Basic Statistics tool is handy for analyzing geospatial data. GIS software is not just useful for creating maps.
Different Scenarios
Scenario 1 (Comparing Impaired Driving from 2010, 2013 and 2016)
Impaired driving data from 2010.
Impaired driving data from 2013.
Impaired driving data from 2016.
A quick analysis of the maps demonstrates that impaired driving has affected all areas of Ottawa, but consecutively in each year, there were a lot of impaired driving incidents in the downtown core near Rideau-Vanier, conveniently where a lot of bars and clubs are located.
Scenario 2 (Observing trends through mapping: Analyzing break ins in the City of Ottawa in 2010, 2013 and 2016)
Map demonstrating break ins in the year 2010.
Map demonstrating break ins in the year 2013.
Map demonstrating break ins in the year 2016.
After observing all three maps, there was a significant decrease in break ins from the years 2010-2016 throughout the whole city. Maps like these can support programs by demonstrating trends in criminal activity, and to observe what programs work, and which ones don't work.
Conclusion
In conclusion, this tutorial aims to highlight the many aspects of data analyzation that can be performed using GIS software, such as QGIS. It also aims to briefly overview cartographic elements and inform how to create a final product, and how these final products assist in visually analyzing trends in data.
Reference List
- Ottawa Police Service Crime Data. (2017).
The data is gathered from the Carleton University MADGIC Desk’s website.
Ottawa Police Service Crime Data retrieved from: http://madgic.library.carleton.ca/deposit/GIS/Crime_Statistics.zip
- QGIS 3.14 ("Pi") Software, which was downloaded from: