Description Usage Arguments Examples
mun.plot offers the possbility to visualise Swiss municipality-level data on a map.
It uses the geodata that is made publicly available by the
Swiss Federal Statistical Office. The
package comes with geodata for 2016. Additional geodata can be downloaded with
map.load. The arguments cantons, districts and municipalities
make it easy to plot customised maps. The function mun.template provides templates
for data collection.
1 2 3 4 5 6 7 8 9 | mun.plot(bfs_id, data, year, add_geodata_path = ".", endofyear = FALSE,
cantons = NULL, districts = NULL, municipalities = NULL,
lakes = "all", boundaries = "m", boundaries_size = 0.2,
boundaries_color = "white", extrema = "global", continuous = TRUE,
color_continuous = c("#fee5d9", "#a50f15"), color_discrete = c("seq",
"1"), color_na = "gray90", title = NULL, subtitle = NULL,
caption = NULL, legend_title = NULL, legend_position = "bottom",
save = FALSE, filename = "mun_plot.png", dpi = 300, width = NA,
heigth = NA, units = "cm")
|
bfs_id |
a numeric vector with municipality identification numbers as used by the Swiss Federal
Statistical Office corresponding to |
data |
a vector of data at municipality-level. |
year |
numeric. Indicates what map version to plot. Available with package: |
add_geodata_path |
a character string with the path to the folder where additional geodata is saved. |
endofyear |
if |
cantons |
input either numeric (canton identification numbers) or character (canton abbreviations) vector to plot municipalities of selected cantons. |
districts |
input either numeric (district identification numbers) or character (district names) vector to plot municipalities of selected districts. |
municipalities |
input either numeric (municipality identification numbers) or character (municipality names) vector to plot selected municipalities. |
lakes |
input either numeric (lake identification numbers) or character (lakes names) vector to plot
selected lakes. If |
boundaries |
character vector naming the boundaries to map.
|
boundaries_size |
numeric vector that specifies the size of the corresponding element in |
boundaries_color |
character vector that specifies the color of the corresponding element in |
extrema |
if |
continuous |
set to |
color_continuous |
character vector with 2 elements to specifiy the plot color if |
color_discrete |
character vector with 2 elements to specifiy the plot color if
|
color_na |
color of missing values. |
title, subtitle, caption, legend_title |
text for titles or caption below the plot. |
legend_position |
the position of the legend ("none", "left", "right", "bottom", "top") |
save |
if |
filename |
file name to create on disk incl. image file format (".jpeg", ".png", ".tiff", etc.). |
dpi |
plot resolution. Applies only to raster output types. |
width, heigth, units |
plot size in units ("in", "cm", or "mm"). If not supplied, uses the size of current graphics device. |
1 2 3 4 5 6 7 8 9 10 | # Generating sample data:
dt <- mun.template(2016)
for(i in 1:nrow(dt)){dt$values[i] <- sample(c(300:700), 1)/1000}
# Plotting sample data:
mun.plot(dt$bfs_nr, dt$values, 2016)
# Plotting sample data for the canton of Aargau:
mun.plot(dt$bfs_nr, dt$values, 2016, cantons = c("AG"),
lakes = c("Hallwilersee"))
|
sh: 1: cannot create /dev/null: Permission denied
sh: 1: cannot create /dev/null: Permission denied
Warning message:
Use of `data_combined$data` is discouraged. Use `data` instead.
Warning messages:
1: Use of `data_combined$data` is discouraged. Use `data` instead.
2: Removed 2 row(s) containing missing values (geom_path).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.