R/Import_2017.R

Defines functions import_2017

Documented in import_2017

#' Import Data from year 2017
#'
#' @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_2017 <- function(x) {
  temp <- tempfile()
  download.file(
    "https://unfallatlas.statistikportal.de/app/UnfalldatenDownload/Unfallorte2017_LinRef_Shapefile.zip",
    temp
  )
  unzip(temp)
  y_17 <-
    read_sf("./Shapefile/Unfallorte2017_LinRef.shp",
            "Unfallorte2017_LinRef")
  y17 <- c(
    "ULAND",
    "UREGBEZ",
    "UKREIS",
    "UGEMEINDE",
    "UJAHR",
    "UMONAT",
    "USTUNDE",
    "UWOCHENTAG",
    "UKATEGORIE",
    "UART",
    "UTYP1",
    "IstRad",
    "IstPKW",
    "IstFuss",
    "IstKrad",
    "IstSonstig",
    "ULICHTVERH",
    "STRZUSTAND",
    "LINREFX",
    "LINREFY",
    "geometry"
  )
  y_17 <- setNames(y_17, y17)
  y_17 <- st_as_sf(y_17)
  y_17 <- st_transform(y_17, 25832)
  return(y_17)
}
LasMal/DestatisR documentation built on March 21, 2020, 7 p.m.