Uses the tmap package to generate a thematic map at the
county level. Input consists of a dataframe with countyFIPS
identifiers.
countyMap(
data = NULL,
parameter = NULL,
state_SFDF = "USCensusStates_02",
county_SFDF = "USCensusCounties_02",
palette = "YlOrBr",
breaks = NULL,
style = ifelse(is.null(breaks), "pretty", "fixed"),
showLegend = TRUE,
legendOrientation = "vertical",
legendTitle = NULL,
conusOnly = TRUE,
stateCode = NULL,
projection = NULL,
stateBorderColor = "gray50",
countyBorderColor = "white",
title = NULL
)
Dataframe containing values to plot. This dataframe
must contain a column named countyFIPS
with the 5-digit FIPS code.
Name of the column in data
to use for
coloring the map.
simple features data frame with US states. It's data
@slot
must contain a column named stateCode
if either
conusOnly = TRUE
or the stateCode
argument is specified.
simple features data frame with US counties. It's data
@slot
must always contain a column named and countyFIPS
and a
column named stateCode
if either conusOnly = TRUE
or the
stateCode
argument is specified.
Palette name or a vector of colors based on RColorBrewer or Viridis.
Numeric vector of break points.
Method to process the color scale.
Logical specifying whether or not to draw the legend
Orientation of the legend. Either 'vertical' or 'horizontal'
Text string to use as the legend title.
Logical specifying Continental US state codes. Ignored when
the stateCode
argument is specified.
Vector of state codes to include on the map.
Specified method to represent surface of Earth.
Color used for state borders.
Color used for county borders.
Text string to use as the plot title.
A ggplot object.
See tmap::tm_fill()
for a more detailed description of
the following parameters:
palette
breaks
Color palettes can be chosen from either RColorBrewer or Viridis. See
tmaptools::palette_explorer()
for a list of available palletes.
# \donttest{
library(MazamaSpatialPlots)
countyMap(
data = example_US_countyCovid,
parameter = "cases",
breaks = c(0,100,200,500,1000,2000,5000,10000,20000,50000,1e6),
title = "COVID-19 Cases on June 01 2020"
)
countyMap(
data = example_US_countyCovid,
parameter = "deaths",
state_SFDF = USCensusStates_02,
county_SFDF = USCensusCounties_02,
palette = "OrRd",
breaks = c(0, 1, 50, 100, 250, 500, 1000, 2500, 3000),
stateCode = c( "NY", "PA", "MD", "NJ", "DE"),
stateBorderColor = "black",
countyBorderColor = 'grey70',
title = "COVID-19 Deaths* in the Mid Atlantic"
) +
tmap::tm_layout(
main.title.size = 1.2,
main.title.color = "white",
attr.color = 'white',
bg.color = "dodgerblue4"
) +
tmap::tm_credits("*as of June 01, 2020", col = "white", position = "left")
# }