Description Usage Arguments Examples
dis.plot
offers the possbility to visualise Swiss district-level data on a map.
It uses the geodata that is made publicly available by the
Swiss Federal Statistical Office. Geodata
is available for the period between 2001
to 2017
. The arguments cantons
,
and districts
make it easy to plot customised maps.
The function dis.template
provides templates for data collection.
1 2 3 4 5 6 7 8 | dis.plot(bfs_id, data, year, add_geodata_path = ".", endofyear = FALSE,
cantons = NULL, districts = NULL, lakes = "all", boundaries = "d",
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 = "dis_plot.png",
dpi = 300, width = NA, heigth = NA, units = "cm")
|
bfs_id |
a numeric vector with district identification numbers as used by the Swiss Federal Statistical
Office corresponding to |
data |
a vector of data at district-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 district of selected cantons. |
districts |
input either numeric (district identification numbers) or character (district names) vector to plot selected districts. |
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 <- dis.template(2016)
for(i in 1:nrow(dt)){dt$values[i] <- sample(c(300:700), 1)/1000}
# Plotting sample data:
dis.plot(dt$bfs_nr, dt$values, 2016)
# Plotting sample data for the canton of Aargau:
dis.plot(dt$bfs_nr, dt$values, 2016, cantons = c("AG"),
lakes = c("Hallwilersee"))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.