Skip to content

Commit

Permalink
Update replace_by_existing function to increase generality
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaCartuyvels1 committed Feb 4, 2024
1 parent cd6ea4f commit 7c4ee78
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 17 additions & 1 deletion source/R/steekproeftrekking_nabehandeling.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,32 @@ thin_sample <- function(sample, thin_dist) {

replace_by_existing <- function(sample,
existing_points,
id_existing_points,
gebied,
overlap_prop = 0.5,
sbp_file) {
# Determine where HOL and OL is in gebied
ol <- selectie_openheid(
gebied = gebied,
ol_strata = c("OL"))

hol <- selectie_openheid(
gebied = gebied,
ol_strata = c("HOL"))
# Recalculate sbp stratum existing points
old_points <- existing_points %>%
filter(st_within(., perimeters_data, sparse = FALSE)) %>%
mutate(is_sbp = st_intersects(.,
st_union(sbp_file),
sparse = FALSE) %>%
as.logical()
) %>%
mutate(openheid_klasse = ifelse(grepl("HOL", stratum), "HOL", "OL")) %>%
mutate(openheid_klasse = ifelse(st_within(., hol, sparse = FALSE),
"HOL",
ifelse(st_within(., ol, sparse = FALSE),
"OL",
NA))) %>%
rename(definitief_punt = id_existing_points) %>%
select(definitief_punt, openheid_klasse, is_sbp)

# Add buffers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@ list(
replace_by_existing(
sample = steekproef_thinned,
existing_points = existing_data,
id_existing_points = id,
gebied = perimeters_data,
overlap_prop = 0.5,
sbp_file = do.call(rbind.data.frame, sbp_akkervogels)
),
Expand Down

0 comments on commit 7c4ee78

Please sign in to comment.