-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #50 from Metropolitan-Council/update-geography-fun…
…ctions Update geography functions
- Loading branch information
Showing
15 changed files
with
325 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
Type: Package | ||
Package: councilR | ||
Title: Functions and Templates for the Metropolitan Council | ||
Version: 0.1.4 | ||
Date: 2022-10-14 | ||
Version: 0.1.5 | ||
Date: 2022-10-31 | ||
Authors@R: c( | ||
person("Metropolitan Council", role = "cph"), | ||
person("Liz", "Roten", , "[email protected]", role = c("cre", "aut"), | ||
|
@@ -33,7 +33,9 @@ Imports: | |
sf (>= 0.9.5), | ||
tictoc (>= 1.0), | ||
tigris (>= 1.6.1), | ||
utils | ||
utils, | ||
ggspatial (>= 1.1.6), | ||
dplyr (>= 1.0.10) | ||
Suggests: | ||
citr (>= 0.3.2), | ||
cowplot (>= 1.1.1), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#' @title Council map starters | ||
#' | ||
#' @description Building on functionality for creating maps when mapping continuous data, `map_council_continuous()` could save some work. | ||
#' | ||
#' @param df The `sf` object to be mapped | ||
#' @param .fill For continuous data, the variable (column name) which | ||
#' should be used to fill polygons | ||
#' @param .lwd numeric, line width of polygons, default setting is `0.5`. | ||
#' @param .low character, color name or hex code to fill the lowest number. | ||
#' Default is `"#8c510a"` (brown) | ||
#' @param .mid character, color name or hex code to fill the midpoint number. | ||
#' Default is `"white"` | ||
#' @param .high character, color name or hex code to fill the highest number. | ||
#' Default is `"#01665e"` (teal) | ||
#' @param .midpoint numeric, midpoint of a diverging color scheme. | ||
#' Default is `0`. | ||
#' | ||
#' @return a [ggplot2] plot | ||
#' @export | ||
#' | ||
#' @family aesthetics | ||
#' | ||
#' @note This function relies on `[{rlang}]` internal functions. | ||
#' | ||
#' @examples | ||
#' \dontrun{ | ||
#' library(ggplot2) | ||
#' library(councilR) | ||
#' | ||
#' fetch_ctu_geo() %>% | ||
#' map_council_continuous(.fill = ALAND, .midpoint = 5e7) | ||
#' } | ||
#' | ||
#' @importFrom ggplot2 ggplot geom_sf scale_fill_gradient2 aes | ||
#' @importFrom ggspatial annotation_north_arrow north_arrow_fancy_orienteering annotation_scale | ||
#' @importFrom rlang enquo | ||
#' | ||
|
||
map_council_continuous <- function(df, | ||
.fill, | ||
.lwd = .5, | ||
.low = "#8c510a", | ||
.mid = "white", | ||
.high = "#01665e", | ||
.midpoint = 0) { | ||
|
||
rlang:::check_number(.lwd) | ||
rlang:::check_number(.midpoint) | ||
|
||
df %>% | ||
ggplot2::ggplot() + | ||
ggplot2::geom_sf(aes(fill = !!enquo(.fill)), lwd = .lwd) + | ||
theme_council_geo() + | ||
ggplot2::scale_fill_gradient2(low = .low, mid = .mid, | ||
high = .high, midpoint = .midpoint) + | ||
ggspatial::annotation_scale( | ||
location = "bl", | ||
bar_cols = c("grey60", "white") | ||
) + | ||
ggspatial::annotation_north_arrow( | ||
location = "tr", which_north = "true", | ||
# pad_x = unit(0.4, "in"), pad_y = unit(0.4, "in"), | ||
style = north_arrow_fancy_orienteering( | ||
fill = c("grey40"), | ||
line_col = "grey20" | ||
) | ||
) | ||
} | ||
|
||
#' @rdname map_council_continuous | ||
#' @export | ||
#' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.