#' Import Data from year 2016
#'
#' @param x parameter needs to be left empty
#'
#' @return Returns a spatial features point object containing all accidents available from Destatis
#' @export
#'
#'@importFrom sf read_sf
#' @importFrom sf st_as_sf
#' @importFrom sf st_transform
#' @importFrom stats setNames
#' @importFrom utils download.file
#' @importFrom utils unzip
#'
import_2016 <- function(x) {
temp <- tempfile()
download.file(
"https://unfallatlas.statistikportal.de/app/UnfalldatenDownload/Unfallorte2016_LinRef_Shapefile.zip",
temp
)
unzip(temp)
y_16 <-
read_sf("./Shapefile/Unfallorte2016_LinRef.shp",
"Unfallorte2016_LinRef")
y16 <- c(
"ULAND",
"UREGBEZ",
"UKREIS",
"UGEMEINDE",
"UJAHR",
"UMONAT",
"USTUNDE",
"UWOCHENTAG",
"UKATEGORIE",
"UART",
"UTYP1",
"IstRad",
"IstPKW",
"IstFuss",
"IstKrad",
"IstSonstig",
"ULICHTVERH",
"STRZUSTAND",
"LINREFX",
"LINREFY",
"geometry"
)
y_16 <- setNames(y_16, y16)
y_16$UJAHR[y_16$UJAHR == "16"] <- "2016"
y_16 <- st_as_sf(y_16)
y_16 <- st_transform(y_16, 25832)
return(y_16)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.