|
10 | 10 | #' |
11 | 11 | #' @name teow |
12 | 12 | #' @keywords resource |
| 13 | +#' @param path A character vector to the Terrestrial Ecoregions of the World (TEOW) |
| 14 | +#' zip file. Note, that the file has to be downloaded manually. |
13 | 15 | #' @returns A function that returns an `sf` footprint object. |
14 | 16 | #' @references Olson, D. M., Dinerstein, E., Wikramanayake, E. D., Burgess, N. D., |
15 | 17 | #' Powell, G. V. N., Underwood, E. C., D’Amico, J. A., Itoua, I., Strand, H. E., |
16 | 18 | #' Morrison, J. C., Loucks, C. J., Allnutt, T. F., Ricketts, T. H., Kura, Y., Lamoreux, |
17 | 19 | #' J. F., Wettengel, W. W., Hedao, P., Kassem, K. R. 2001. Terrestrial ecoregions of |
18 | 20 | #' the world: a new map of life on Earth. Bioscience 51(11):933-938. |
19 | 21 | #' \doi{https://doi.org/10.1641/0006-3568(2001)051[0933:TEOTWA]2.0.CO;2} |
20 | | -#' @importFrom utils unzip |
| 22 | +#' @source \url{https://files.worldwildlife.org/wwfcmsprod/files/Publication/file/6kcchn7e3u_official_teow.zip} |
21 | 23 | #' @include register.R |
22 | 24 | #' @export |
23 | | -get_teow <- function() { |
| 25 | +# get_teow <- function() { |
| 26 | +# function(x, |
| 27 | +# name = "teow", |
| 28 | +# type = "vector", |
| 29 | +# outdir = mapme_options()[["outdir"]], |
| 30 | +# verbose = mapme_options()[["verbose"]]) { |
| 31 | +# url <- paste( |
| 32 | +# "/vsizip//vsicurl/", |
| 33 | +# "https://files.worldwildlife.org/wwfcmsprod/files/", |
| 34 | +# "Publication/file/6kcchn7e3u_official_teow.zip/", |
| 35 | +# "official/wwf_terr_ecos.shp", |
| 36 | +# sep = "" |
| 37 | +# ) |
| 38 | +# bbox <- c(xmin = -180.0, ymin = -90.0, xmax = 180.0, ymax = 84.0) |
| 39 | +# tile <- st_as_sf(st_as_sfc(st_bbox(bbox, crs = "EPSG:4326"))) |
| 40 | +# tile[["source"]] <- url |
| 41 | +# make_footprints(tile, filenames = "wwf_terr_ecos.gpkg", what = "vector") |
| 42 | +# } |
| 43 | +# } |
| 44 | + |
| 45 | +get_teow <- function(path = NULL) { |
| 46 | + if (is.null(path) || !endsWith(tolower(path), ".zip")) { |
| 47 | + stop("Expecting path to point towards an existing '.zip' file.") |
| 48 | + } |
| 49 | + |
24 | 50 | function(x, |
25 | 51 | name = "teow", |
26 | 52 | type = "vector", |
27 | 53 | outdir = mapme_options()[["outdir"]], |
28 | 54 | verbose = mapme_options()[["verbose"]]) { |
29 | | - url <- paste( |
30 | | - "/vsizip//vsicurl/", |
31 | | - "https://files.worldwildlife.org/wwfcmsprod/files/", |
32 | | - "Publication/file/6kcchn7e3u_official_teow.zip/", |
33 | | - "official/wwf_terr_ecos.shp", |
34 | | - sep = "" |
| 55 | + url <- paste0( |
| 56 | + "/vsizip/", |
| 57 | + path, |
| 58 | + "/official/wwf_terr_ecos.shp" |
35 | 59 | ) |
36 | 60 | bbox <- c(xmin = -180.0, ymin = -90.0, xmax = 180.0, ymax = 84.0) |
37 | | - tile <- st_as_sf(st_as_sfc(st_bbox(bbox, crs = "EPSG:4326"))) |
| 61 | + tile <- sf::st_as_sf(sf::st_as_sfc(sf::st_bbox(bbox, crs = "EPSG:4326"))) |
38 | 62 | tile[["source"]] <- url |
39 | 63 | make_footprints(tile, filenames = "wwf_terr_ecos.gpkg", what = "vector") |
40 | 64 | } |
|
0 commit comments