knitr::opts_chunk$set(echo = TRUE, warning = TRUE, message = TRUE,
                      fig.width = 9, fig.height = 6, dpi = 500, 
                      retina = 1, fig.showtext = TRUE)

Setup

# devtools::install_github("EcoDynIZW/d6")
# devtools::install_github("EcoDynIZW/d6geodata")

sapply(list("sf", "tidyverse", "terra", "here" , "d6geodata", "d6"), 
       library, character.only = TRUE, logical.return = TRUE)

create folder

data_name <- d6geodata::data_name()

path <- here("data", unlist(str_split(data_name, "_"))[2], data_name)

dir.create(path = here::here(path))

Data

(germany_3035_sf <- st_read(here("data", 
                                 "germany",
                                 "administrativ-units_germany_2020_polygon_28532_gpkg",
                                 "administrativ-units_germany_2020_polygon_28532.gpkg")) %>% 
   dplyr::select(GEN) %>% 
   st_transform(3035)
 )

berlin_3035_sf <-
  st_read(
    here(
      "data",
      "berlin",
      "districs_berlin_2022_poly_03035_gpkg",
      "districs_berlin_2022_poly_03035.gpkg"
    )
  )

processing

tif <- 

terra::writeRaster(tif, here(path, stringi::stri_replace_last_fixed(data_name, "_", ".")), overwrite = TRUE)

create meta data file

meta <- dplyr::tibble(
  folder_name = data_name,
  name = stringi::stri_replace_last_fixed(data_name, "_", "."),
  epsg = ,
  crs = st_crs()$proj4string,
  year_of_data = ,
  units_of_data = "",
  resolution = "",
  type_of_data = d6geodata:::fun_type(),
  type_of_file = d6geodata:::fun_file(),
  date_of_compile = as.character(Sys.Date()),
  source = d6geodata:::fun_source(),
  short_description = "",
  modified = NA
) |> 
   mutate(link_of_source = d6geodata:::fun_source_link(x = source),
          copyright = d6geodata:::get_copyright(source))


write.table(meta, base::paste0(path, "/meta-data_", 
    data_name, ".csv"), row.names = FALSE, sep = ",")

plot file

tif_plot <- tif

if(meta$type_of_data == 'binary_categorical') {
  p_map <- d6geodata::plot_binary_map(tif = tif_plot)
  }
if(meta$type_of_data %in% c('continuous_numeric', 'discrete_numeric')) {
  p_map <- d6geodata::plot_quantitative_map(tif = tif_plot)
}
if(meta$type_of_data %in% c('unordered_categorical', 'ordered_categorical')) {
  p_map <- d6geodata::plot_qualitative_map(tif = tif_plot)
}

saveRDS(p_map, here(path, paste0(data_name, ".rds")))

create html file

d6geodata::create_report(path_name = data_name, out_path = paste0(stringi::stri_c((
      unlist(stringi::stri_split(path, regex = "/"))[-c(1:which(unlist(stringi::stri_split(path, regex = "/")) %in% "GeoData")-1)]
    ), collapse = "/")), cats = c())

Session Info

## DO NOT REMOVE!
Sys.time()
#git2r::repository() ## uncomment if you are using GitHub
sessionInfo()



EcoDynIZW/d6geodata documentation built on Sept. 30, 2024, 2:15 p.m.