Skip to content

Commit

Permalink
Merge pull request #5 from inbo/checklist_updates
Browse files Browse the repository at this point in the history
Checklist and renv updates
  • Loading branch information
EmmaCartuyvels1 authored Jan 22, 2024
2 parents 91d99a7 + da3f2dc commit e1d4732
Show file tree
Hide file tree
Showing 19 changed files with 1,037 additions and 1,872 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ Instituut voor Natuur- en Bosonderzoek (INBO)[^cph][^fnd]
<!-- description: start -->
De toestand van de biodiversiteit in het agrarisch gebied gaat achteruit, met negatieve gevolgen voor de biodiversiteit buiten het landbouwgebied, voor de landbouw zelf en voor de veerkracht tegenover klimaatverandering. Met het Meetnet Biodiversiteit Agrarisch Gebied (MBAG) trachten we deze toestand beter op te volgen, als basis voor gerichte maatregelen om de achteruitgang te keren. Dit deelproject legt de basis voor een meetnet voor agrarische soorten (MAS).

Dit in kaart brengen gebeurt op een snelle en efficiënte manier via puntentellingen, waarbij alle vogels en zoogdieren (o.a. haas, ree en vos) worden genoteerd binnen een straal van 300m, op vier momenten tijdens het broedseizoen. In 2023 bestrijken we de Leemstreek, de Moeren en de Zandleemstreek, in 2024 willen we een meetnet uitrollen met zeggingskracht over heel Vlaanderen.
Dit in kaart brengen gebeurt op een snelle en efficiënte manier via puntentellingen, waarbij alle vogels en zoogdieren (o.a. haas, ree en vos) worden genoteerd binnen een straal van 300 m, op vier momenten tijdens het broedseizoen. In 2023 bestrijken we de Leemstreek, de Moeren en de Zandleemstreek, in 2024 willen we een meetnet uitrollen met zeggingskracht over heel Vlaanderen.
<!-- description: end -->
2 changes: 2 additions & 0 deletions checklist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ spelling:
ignore:
- .github
- LICENSE.md
- source/targets
- source/R
91 changes: 91 additions & 0 deletions inst/nl_be.dic
Original file line number Diff line number Diff line change
@@ -1,8 +1,99 @@
'augmented
'gewasgroep'
'rotating
+
--\
-trekking
.gitignore
.parquet
301ste
Akkervogelgemeenschappen
Avimap
BO's
Bosonderzoek
CHM
Calster
Cartuyvels
DHMV
DSM
DTM
Digital
GL
GVI
Gittargets
HGL
KLA
KLE's
KML
Langeraert
MBAG
Natuur-
OL
OLA
Repository
SB
SBP
SBP's
SBP’s
SBPs
SOVON
Surface
Terrain
Union
Version
\
aeroway
batching
canopy
cf
coden
coding
confounders
confounding
control
cvvi
design'
exclusiekaart
git2rdata
globals
half-open
height
highway
landgebruiksamenstelling
landuse
layers
leemstreek.Rmd
lijn-
lm.Rmd
lm.Rproj
mas
monocotylen
multipolygon
openness
perceelsgrootte
perimeters.gpkg
pipeline
pointid
polygon
positive
puntenset
rastercel
reserveset
spatiale
statistical
ste
stratumoppervlakte
telcirkel
telcirkels
telpunt
telpunten
tertiare
thinning
topographic
union
version
viewshed
visibility
x-
y-coördinaten
zn
8 changes: 4 additions & 4 deletions source/R/draw_sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ draw_sample <- function(
)

sampling_frame$in_sample <-
ifelse(1:nrow(sampling_frame) %in% draw, TRUE, FALSE)
ifelse(seq_len(nrow(sampling_frame)) %in% draw, TRUE, FALSE)
sampling_frame$sample_order <- NA
for (i in 1:length(draw)) {
for (i in seq_along(draw)) {
sampling_frame$sample_order[draw[i]] <- i
}
sample_df <- sampling_frame[sampling_frame$in_sample, ]
sample_df <- sample_df %>%
arrange(sample_order) %>%
mutate(batch = ifelse(sample_order <= sample_size,
"eerste set" ,
"eerste set",
"reserve set"))

return(sample_df)
Expand All @@ -90,7 +90,7 @@ allocatie <- function(steekproefkader,
target_samplesize = 410,
popsize_minimum = 410,
allocatie_binnen_sbp = 0.5,
allocatie_leemstreek = 350/410,
allocatie_leemstreek = 350 / 410,
ol_strata = c("OL", "HOL")) {
allocatie <- steekproefkader %>%
st_drop_geometry() %>%
Expand Down
13 changes: 7 additions & 6 deletions source/R/geocomputations.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
point_to_gridcell <- function(
xy,
cell_width_m = 500,
point_position = c("center", "lowerleft", "upperleft", "lowerright", "upperright"),
point_position = c("center", "lowerleft",
"upperleft", "lowerright", "upperright"),
crs = 31370) {
point_position <- match.arg(point_position)

Expand All @@ -28,8 +29,8 @@ point_to_gridcell <- function(
nQuadSegs = 1)

# rotate 45 degrees around centroid
rot <- function(a) matrix(c(cos(a), sin(a), -sin(a), cos(a)), 2, 2)
pl <- (xy_buffer - xy) * rot(pi/4) + xy
rot <- function(a) matrix(c(cos(a), sin(a), - sin(a), cos(a)), 2, 2)
pl <- (xy_buffer - xy) * rot(pi / 4) + xy
pl <- sf::st_sf(data.frame(xy_df, pl), crs = crs)
return(pl)
}
Expand All @@ -39,7 +40,8 @@ point_to_gridcell <- function(
#'
#' @param grid_cell A polygon within which boundaries zonal statistics will be
#' calculated
#' @param layer A rasterlayer containing land use classes or a polygon layer (sf object)
#' @param layer A rasterlayer containing land use classes or
#' a polygon layer (sf object)
#' @param grid_group_by_col A character vector of columns to group by for zones
#' @param layer_group_by_col A character vector of columns to group by for
#' layer
Expand All @@ -56,7 +58,7 @@ landusemetrics_grid_cell <- function(
progress = FALSE
) {
require(duckdb)
if (inherits(layer, "SpatRaster") | inherits(layer, "RasterLayer")) {
if (inherits(layer, "SpatRaster") || inherits(layer, "RasterLayer")) {
crs_grid <- gsub("^((.*?),\\n\\s*?){2}", "", sf::st_crs(grid_cell)$wkt)
crs_layer <- gsub("^((.*?),\\n\\s*?){2}", "", terra::crs(layer))
assertthat::assert_that(crs_grid == crs_layer)
Expand Down Expand Up @@ -110,4 +112,3 @@ landusemetrics_grid_cell <- function(
return(int)
}
}

16 changes: 6 additions & 10 deletions source/R/landuse_maps.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ lum_download <- function(
}


#testje <- sf::st_layers("Z:/Projects/PRJ_NARA_2020/Target_2/Extra_LGdatalagen.gdb")
#testje2 <- sf::st_layers("Z:/Projects/PRJ_NARA_2020/Basisbestanden/Basisdata.gdb")


#' read land use maps from inbo projects folder
#'
#' @param year one of "2013" or "2016"
Expand All @@ -50,17 +46,18 @@ lum_download <- function(
#' @examples
lum_read_from_inbo <- function(
year = c("2016", "2013"),
layerid = c("finaal_natuurbeheer", "niveau1", "niveau2", "niveau3", "niveau4"),
layerid = c("finaal_natuurbeheer", "niveau1",
"niveau2", "niveau3", "niveau4"),
root = "data/landgebruik/inbo",
add_levels = FALSE) {
require(dplyr)
require(readr)
year <- match.arg(year)
layerid <- match.arg(layerid)
file <- paste0("LG", year, "_", layerid,".tif")
file <- paste0("LG", year, "_", layerid, ".tif")
tr <- terra::rast(file.path(root, file))
# re-assign categories labels which got lost in translation
# (ESRI -> geotiff -> terra::rast)
# (ESRI to geotiff to terra::rast)
if (add_levels) {
legend <- read_csv2(
"data/landgebruik/legende_landgebruik.csv",
Expand Down Expand Up @@ -104,10 +101,10 @@ lum_read_from_vito <- function(
require(dplyr)
require(readr)
year <- match.arg(year)
file <- paste0("lu_landgebruik_vlaa_", year, "_v2",".tif")
file <- paste0("lu_landgebruik_vlaa_", year, "_v2", ".tif")
tr <- terra::rast(file.path(root, file))
# re-assign categories labels which got lost in translation
# (ESRI -> geotiff -> terra::rast)
# (ESRI to geotiff to terra::rast)
if (add_levels) {
oldwd <- setwd(root)
legend <- read_csv2(
Expand Down Expand Up @@ -149,4 +146,3 @@ lum_read_from_vito <- function(

return(tr)
}

Loading

0 comments on commit e1d4732

Please sign in to comment.