ComeçarComece de graça

Obtaining data for cartography with tigris

Before making your dot-density map of Washington, DC with ggplot2, it will be useful to acquire some ancillary cartographic data with the tigris package that will help map viewers understand what you've visualized. These datasets will include major roads in DC; area water features; and the boundary of the District of Columbia, which you'll use as a background in your map.

Este exercício faz parte do curso

Analyzing US Census Data in R

Ver curso

Instruções do exercício

  • Get a roads dataset for Washington, DC with the roads() function, and filter the result for major roads in the District.
  • Use the area_water() function from tigris to get an area water features dataset.
  • Obtain the boundary of DC by using tigris's counties() function.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Filter the DC roads object for major roads only
dc_roads <- ___("DC", "District of Columbia") %>%
  ___(RTTYP %in% c("I", "S", "U"))

# Get an area water dataset for DC
dc_water <- ___("DC", "District of Columbia")

# Get the boundary of DC
dc_boundary <- ___("DC", cb = TRUE)
Editar e executar o código