-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathget_resolution.R
37 lines (37 loc) · 1.32 KB
/
get_resolution.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#'@inheritParams ahn_area
#'@noRd
get_resolution <- function(AHN = "AHN", resolution) {
if (AHN == "AHN1") {
if (resolution == "") {
message()("No resolution was found for importing AHN1. Resolution of 5 meters will be used.")
resolution <- 5
resolution_name <- "5m"
} else if (resolution != 5 && resolution != 100) {
warning("No correct resolution was found for importing AHN1. Resolution of 5 m will be used.")
resolution <- 5
resolution_name <- "5m"
} else {
resolution <- resolution
resolution_name <- paste0(resolution, "m")
}
} else if (AHN %in% AHN_05res_versions) {
if (resolution == "") {
message(paste0("No resolution was found for importing ", AHN, ". Resolution of 0.5 meters will be used."))
resolution <- 0.5
resolution_name <- "05m"
} else {
if (resolution == 0.5) {
resolution_name <- "05m"
} else if (resolution == 5) {
resolution_name <- "5m"
} else {
warning(paste0("No correct resolution was found for importing ", AHN, ". Resolution of 0.5 meters will be used."))
resolution <- 0.5
resolution_name <- "05m"
}
}
} else {
stop("Error in getting the resolution.")
}
return(list("res" = resolution, "res_name" = resolution_name))
}