knitr::opts_chunk$set( collapse = TRUE # comment = "#>" )
This is a tutorial using the ChicagoPackage. This tutorial mainly concerns the shapes in the package, namely the community areas, police wards and beats, and cencus tracts.
### load the relevant packages library(ChicagoPackage) library(tmap) library(sf) library(rgeos) library(rgdal) library(spdep) library(dplyr)
This Chicago Data Package contains different shapes, and this tutorial will show you what each individual shape looks like and how you might want to use them.
# Seeing the properties of the community area dataset head(ca_boundaries) # Plotting community areas, by the area tm_shape(ca_boundaries) + tm_polygons("shape_area", palette = "Greens") + tm_layout(main.title = "Community Areas")
# Again, properties head(census_tracts_2010) # Plotting census tracts, by their community areas tm_shape(census_tracts_2010) + tm_polygons("commarea", palette = "Set3") + tm_layout(main.title = "2010 Census Tracts") # We notice that there is a warning message, saying that there are more levels of community areas than the color palette, which is fine. As a result, some areas are grouped using the same color, resulting in larger areas.
# Same procedures as before head(police_beats2019) tm_shape(police_beats2019) + tm_polygons("beat", palette = "Accent") + tm_layout(main.title = "Police Beats")
# Same procedures as before head(wards2019) tm_shape(wards2019) + tm_polygons("ward", palette = "Paired") + tm_layout(main.title = "Police Wards")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.