For this project, I built a chloropleth map (sometimes called heatmaps) that visualizes the crime rate in each of the LSOA areas within Manchester.

All credit for the instructions and data go to Crime Mapping and Spatial Data Analysis using R by Juanjo Medina and Reka Solymosi.

Code can be found below.

library(tidyverse)
library(readr)
library(dplyr)
library(janitor)
library(skimr)
library(sf)
library(tmap)
library(tmaptools)
library(DCluster)
library(geodaData)
manchester = st_read("https://raw.githubusercontent.com/maczokni/crime_mapping/master/data/manchester.geojson", quiet = TRUE)

manchester <- mutate(manchester, 
                     crimr1 = (count/respop)*100000,  # crime per residential population
                     crimr2 = (count/wkdpop)*100000) # crime per workday population

current_style <- tmap_style("classic")

tm_shape(manchester) + 
  tm_fill("crimr1", title = "Crime per 100,000 residents") +
  tm_borders(alpha = 0.1)
  tm_layout(main.title = "Crime in Manchester City, Nov/2017", 
            main.title.size = 0.7 ,
            legend.outside = TRUE,  # Place legend outside of map 
            legend.title.size = 0.8) 
## $tm_layout
## $tm_layout$legend.outside
## [1] TRUE
## 
## $tm_layout$legend.title.size
## [1] 0.8
## 
## $tm_layout$main.title
## [1] "Crime in Manchester City, Nov/2017"
## 
## $tm_layout$main.title.size
## [1] 0.7
## 
## $tm_layout$style
## [1] NA
## 
## 
## attr(,"class")
## [1] "tm"