Working with Spatial data

  • tmap uses ESRI Shapefiles
  • read them in using read_shape
  • Shortcut to creating maps qtm
    • quick thematic map
  • tmap objects quite similar to ggplot objects
  • First up, load the packages you need
    • tmap works well with dplyr
library(tmap)
library(dplyr)

Create the map…

read_shape('./counties/counties.shp') -> cty 
cty %>% qtm

Adding a variable to the map

cty %>% qtm(fill="POPDENSITY")

Adding decorations

cty %>% qtm(fill='POPDENSITY') -> cty_dens
cty_dens + tm_compass()