# INBO CODING CLUB 24 November 2022 Welcome! ## Share your code snippet If you want to share your code snippet, copy paste your snippet within a section of three backticks (```): As an **example**: ``` library(tidyverse) ``` (*you can copy paste this example and add your code further down*) ## Yellow sticky notes No yellow sticky notes online. Put your name + " | " and add a "*" each time you solve a challenge (see below example where Damiano solved all three challenges). ## Participants Name | Challenges --- | --- Damiano Oldoni | *** Dirk Maes | *** Wim Kuypers | Natalie Beenaerts | Teun Everts | Raïsa Carmen | * Wouter Depaepe | * ## Challenge 1 ``` Solution Raïsa ## CHALLENGE 1 lu_nara_2016 <- terra::rast(x = "./data/20221124/20221124_lu_nara_2016_100m.tif") #2. names(lu_nara_2016) crs(lu_nara_2016) ext(lu_nara_2016) res(lu_nara_2016) minmax(lu_nara_2016) #3. plot(lu_nara_2016) # 4. Read `20211125_lu_nara_legend.csv` (code is provided!) so that you can set # the color table associated with `lu_nara_2016`. legend <- read.delim( "./data/20221124/20221124_lu_nara_legend.txt", sep = ",") legend plot(lu_nara_2016, type = "classes", col = legend$color, levels = legend$land_use) #' 5. Calculate the most and least occurring land use category in each of the #' Natura2000 protected areas (read these areas using the provided code). Tip: use exactextractr::exact_extract() and find #' the right [summary operations](https://isciences.gitlab.io/exactextractr/#summary-operations) natura2000 <- st_read("./data/20211125/20211125_protected_areas_Lambert72.gpkg", layer = "ps_hbtrl") # make dataframes with the name of the Natura2000 area, the majority/minority id and name majority <- natura2000 %>% st_drop_geometry() %>% dplyr::select(NAAM) %>% mutate(majority = exact_extract(lu_nara_2016, natura2000, fun = "majority")) %>% left_join(dplyr::select(legend, id, land_use), by = c("majority" = "id")) minority <- natura2000 %>% st_drop_geometry() %>% dplyr::select(NAAM) %>% mutate(minority = exact_extract(lu_nara_2016, natura2000, fun = "minority")) %>% left_join(dplyr::select(legend, id, land_use), by = c("minority" = "id")) ``` ## Challenge 2 ## INTERMEZZO ## Challenge 3 ## Bonus challenge