-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathne_coastline.R
44 lines (38 loc) · 1.01 KB
/
ne_coastline.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
38
39
40
41
42
43
44
#' Get natural earth world coastline
#'
#' returns world coastline at specified scale
#'
#' @inherit ne_download
#'
#' @examples
#' if (requireNamespace("rnaturalearthdata")) {
#' coast <- ne_coastline()
#' plot(coast)
#' }
#'
#' @export
ne_coastline <- function(scale = 110L, returnclass = c("sf", "sv")) {
returnclass <- match.arg(returnclass)
if (returnclass == "sp") {
deprecate_sp("ne_download(returnclass = 'sp')")
}
# check for the data packages and try to install if not there
if (scale == 10L) {
check_rnaturalearthhires()
} else {
check_rnaturalearthdata()
}
# check on permitted scales, convert names to numeric
scale <- check_scale(scale)
# choose which map based on scale
sldf <- NULL
if (scale == 110L) {
sldf <- rnaturalearthdata::coastline110
} else if (scale == 50L) {
sldf <- rnaturalearthdata::coastline50
} else if (scale == 10L) {
sldf <- rnaturalearthhires::coastline10
}
# Convert to the desired class
convert_spatial_class(sldf, returnclass)
}