Chapter 1 Producing Your First Crime Map
This chapter introduces some basic concepts and will get you started on making maps using R. We will learn how we can take crime data, and assign the appropriate geometry for our chosen unit of analysis. Spatial or environmental criminologists most often work with data that are discrete. This may include data represented by points (e.g., locations of a crime incident) or counts and rates of crimes within a particular geographical unit (e.g., a neighbourhood, census tract, or municipality). In other scientific disciplines the mapped data may be continuous across the study surface (e.g., temperature). This is less common in our case.
In these first few chapters we will focus on ways to work with discrete data. Firstly, we introduce the spatial and non-spatial R packages used frequently throughout this book, and cover some key terms around projection and coordinate reference systems which will be essential for subsequent chapters. As we will discover throughout the book, there are multiple R packages that have been developed to visualise spatial data. They all have advantages and disadvantages, but many offer similar functionality. Sometimes choosing one or the other is a matter of personal preference. We will introduce many different approaches throughout the book, to allow readers to select their own preferences. In this chapter we will focus on map-making with
ggplot2, a general package for data visualisation (not just maps) based on the theory of the grammar of graphics [153]. If you are not new to R, you may already be familiar with this package. Our intention in this chapter is to introduce enough background to let you to quickly produce your first map. In subsequent chapters we will further refine their look and aesthetic appeal, and discuss the many decisions that go into producing a crime map.
In this chapter we will use the following packages:
# Packages for reading data and data carpentry
library(readr)
library(tibble)
library(janitor)
library(dplyr)
# Packages for handling spatial data
library(sf)
# Packages for visualisation and mapping
library(ggplot2)
library(ggspatial)
If you are a little rusty on R packages, what they do, how to install them, how to load them, and so on, please refer to Appendix A: A quick intro to R and RStudio for a quick introduction and overview of R.
