From 8d4c19c68eb61586f86b4029a805ef6400d6a3ab Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Thu, 6 Jul 2023 17:29:45 +0100 Subject: [PATCH 01/61] Explicitly test e_source failure --- tests/testthat/test-elev.R | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/testthat/test-elev.R diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R new file mode 100644 index 0000000..a8aa97a --- /dev/null +++ b/tests/testthat/test-elev.R @@ -0,0 +1,4 @@ +test_that("elev() fails gracefully", { + expect_error(elev(out = "", location = "", e_source = ""), + "e_source must be ") +}) From 793b6234b4a65ea99cee550fd1b3bd5d8766925e Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:33:00 +0100 Subject: [PATCH 02/61] Use named variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Programming best practice is to avoid using bare numbers, and instead to use variables – that way it is clear where values come from and their relationship to the underlying objects. Where values are changed, it can be easy to miss a hard-coded number (as 1728 here), or to calculate its correct value by hand. --- R/elev.R | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/R/elev.R b/R/elev.R index bb2acb6..6f1d292 100644 --- a/R/elev.R +++ b/R/elev.R @@ -1,10 +1,14 @@ .elev_geodata <- function(location, output_dir) { + y_max <- 80 + y_min <- -70 + tile_degrees <- 5 # create SRTM tiles - rs <- terra::rast(nrows = 24, ncols = 72, + rs <- terra::rast(nrows = (y_max - y_min) / tile_degrees, + ncols = 360 / tile_degrees, xmin = -180, xmax = 180, - ymin = -60, ymax = 60) - rs[] <- 1:1728 + ymin = y_min, ymax = y_max) + rs[] <- seq_len(prod(dim(rs))) # Intersect location and tiles tiles <- unique(terra::extract(rs, terra::vect(location))$lyr.1) From 8143bcac69a1d21cd4680bf72b986918e5a9dad6 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Fri, 7 Jul 2023 09:40:29 +0100 Subject: [PATCH 03/61] Use `apply()` --- R/elev.R | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/R/elev.R b/R/elev.R index 6f1d292..e7a72aa 100644 --- a/R/elev.R +++ b/R/elev.R @@ -13,34 +13,29 @@ # Intersect location and tiles tiles <- unique(terra::extract(rs, terra::vect(location))$lyr.1) srtm_points <- terra::xyFromCell(rs, tiles) - - # Make an empty list to fill - srtm_list <- list() - - # lats lats <- srtm_points[, "y"] - # Downloads the tiles and stores into that list - for (pts in 1:seq_along(lats)) { - - tile <- geodata::elevation_3s( - lon = srtm_points[pts, "x"], lat = srtm_points[pts, "y"], + # Make an empty list to fill + srtm_list <- apply(srtm_points, 1, function (point) { + geodata::elevation_3s( + lon = point["x"], lat = point["y"], path = tempfile() ) - - srtm_list[[pts]] <- tile - - } + }) # Mosaic the tiles in the list if (length(lats) > 1) { srtm_list$fun <- mean srtm_mosaic <- do.call(terra::mosaic, srtm_list) + } else if (length(strm_list) == 0) { + stop("No data downloaded.") # nocov } else { srtm_mosaic <- srtm_list[[1]] } + return(srtm_mosaic) } + #' Download elevation data #' #' @description From 5b1894218298eb8d60437fe08d1e59dd6df97a40 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:50:17 +0100 Subject: [PATCH 04/61] =?UTF-8?q?Tests=20for=20geodata=20=E2=80=93=20which?= =?UTF-8?q?=20required=20some=20reimplementation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- NAMESPACE | 3 + R/elev.R | 71 +++-- tests/testthat/_snaps/elev/geo-elev.svg | 338 ++++++++++++++++++++++++ tests/testthat/test-elev.R | 36 +++ 4 files changed, 428 insertions(+), 20 deletions(-) create mode 100644 tests/testthat/_snaps/elev/geo-elev.svg diff --git a/NAMESPACE b/NAMESPACE index 7a6489f..6216ce9 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -38,11 +38,14 @@ importFrom(sp,SpatialPointsDataFrame) importFrom(sp,SpatialPolygonsDataFrame) importFrom(stats,aggregate) importFrom(stats,sd) +importFrom(terra,"crs<-") importFrom(terra,centroids) +importFrom(terra,colFromCell) importFrom(terra,crds) importFrom(terra,extract) importFrom(terra,mosaic) importFrom(terra,rast) +importFrom(terra,rowFromCell) importFrom(terra,vect) importFrom(terra,writeRaster) importFrom(terra,xyFromCell) diff --git a/R/elev.R b/R/elev.R index e7a72aa..271920e 100644 --- a/R/elev.R +++ b/R/elev.R @@ -1,34 +1,65 @@ -.elev_geodata <- function(location, output_dir) { +#' @importFrom terra colFromCell crs<- rowFromCell +.elev_geodata <- function(location, output_dir, ...) { - y_max <- 80 - y_min <- -70 - tile_degrees <- 5 + y_max <- 60 + y_min <- -60 # create SRTM tiles - rs <- terra::rast(nrows = (y_max - y_min) / tile_degrees, - ncols = 360 / tile_degrees, - xmin = -180, xmax = 180, - ymin = y_min, ymax = y_max) + rs <- terra::rast(res = 5, ymin = y_min, ymax = y_max) rs[] <- seq_len(prod(dim(rs))) # Intersect location and tiles tiles <- unique(terra::extract(rs, terra::vect(location))$lyr.1) - srtm_points <- terra::xyFromCell(rs, tiles) - lats <- srtm_points[, "y"] + cols <- formatC(colFromCell(rs, tiles), width = 2, flag = 0) + rows <- formatC(rowFromCell(rs, tiles), width = 2, flag = 0) + na <- cols == "NA" | rows == "NA" + srtm_id <- paste0("srtm_", cols[!na], "_", rows[!na]) - # Make an empty list to fill - srtm_list <- apply(srtm_points, 1, function (point) { - geodata::elevation_3s( - lon = point["x"], lat = point["y"], - path = tempfile() - ) + temp_file <- tempfile("srtm_", output_dir) + on.exit(unlink(temp_file)) + + srtm_list <- lapply(srtm_id, function(id) { + tif <- paste0(output_dir, "/", id, ".tif") + error <- if (file.exists(tif)) { + 0 + } else { + zip <- paste0( + "https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/", + id, ".zip" + ) + urlStatus <- attr(curlGetHeaders(zip), "status") + error <- if (urlStatus == 200) { + tryCatch( + utils::download.file(url = zip, destfile = temp_file, mode = "wb", + ...), # Returns 0 on success + error = function(e) { + warning("Failed to download ", id, ": ", e) + -1 # Error code + } + ) + } else { + warning("Could not download ", id, ": HTTP status ", urlStatus) + -1 + } + } + if (!error) { + tryCatch(utils::unzip(temp_file, paste0(id, ".tif"), exdir = output_dir), + error = function(e) warning("Failed to unzip: ", id)) + rs <- rast(tif) + crs(rs) <- "+proj=longlat +datum=WGS84" + rs + } else { + NULL + } }) + srtm_list <- srtm_list[!vapply(srtm_list, is.null, logical(1))] + # Mosaic the tiles in the list - if (length(lats) > 1) { + if (length(srtm_list) > 1) { srtm_list$fun <- mean srtm_mosaic <- do.call(terra::mosaic, srtm_list) - } else if (length(strm_list) == 0) { - stop("No data downloaded.") # nocov + } else if (length(srtm_list) == 0) { + stop("No data downloaded.") } else { srtm_mosaic <- srtm_list[[1]] } @@ -120,7 +151,7 @@ elev <- function(output_dir, location, e_source = "mapzen") { overwrite = TRUE) }, { # geodata - srtm_mosaic <- .elev_geodata(location = location) + srtm_mosaic <- .elev_geodata(location, output_dir) file_path <- paste0(output_dir, "/elev/srtm.tif") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) diff --git a/tests/testthat/_snaps/elev/geo-elev.svg b/tests/testthat/_snaps/elev/geo-elev.svg new file mode 100644 index 0000000..b94ff9f --- /dev/null +++ b/tests/testthat/_snaps/elev/geo-elev.svg @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + +155 +160 + + + + + + + +-60 +-58 +-56 +-54 +-52 +-50 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +0 +50 +100 +150 +200 +250 +300 + + + + + + + + + + + + + diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index a8aa97a..f0b622a 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -1,4 +1,40 @@ test_that("elev() fails gracefully", { expect_error(elev(out = "", location = "", e_source = ""), "e_source must be ") + + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + # No data available in the oceans + sea <- sf::st_as_sf( + data.frame(lat = c(-59, -59, -58, -59), + lng = c(-123, -124, -123, -123)), coords = 2:1) + # elev(tmp_dir, tile50) + expect_warning( + expect_error(elev(tmp_dir, sea, "GEOdata"), "No data downloaded"), + "Could not download srtm_12_24" + ) +}) + +test_that("elev()", { + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + + # Two squares, 68_24 and 68_23, cover + # Latitude south: 50-60 + # Longitude east: 155-160 + # We should be able to download these squares even if our target area + # overlaps non-existent neighbouring squares + + island <- sf::st_as_sf( + data.frame(lat = c(-61, -59, -51, -49, -61, -61), + lng = c(161, 159, 159, 161, 154, 161)), coords = 2:1) + + # elev(tmp_dir, island) + expect_warning( + geoElev <- elev(tmp_dir, island, "GEOdata"), + "Could not download srtm_69_22") + + skip_if_not_installed("vdiffr") + library("terra") + vdiffr::expect_doppelganger("geo-elev", function() plot(geoElev)) }) From 03ab7ba5523955ac62c6da7512f3027b5a5688f1 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Fri, 7 Jul 2023 16:13:43 +0100 Subject: [PATCH 05/61] Intermediate edit --- tests/testthat/test-elev.R | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f0b622a..0b66fee 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -29,6 +29,12 @@ test_that("elev()", { data.frame(lat = c(-61, -59, -51, -49, -61, -61), lng = c(161, 159, 159, 161, 154, 161)), coords = 2:1) + # In progress: the below will replace the above. + island <- sf::st_polygon( + list(cbind(lat = c(-61, -49, -61, -61), lng = c(161, 161, 154, 161)))) + # This polygon covers a tile that does not contain a vertex. + # Should this tile be downloaded too? + # elev(tmp_dir, island) expect_warning( geoElev <- elev(tmp_dir, island, "GEOdata"), From b29fca19ec0293076ce126311f994198114d6d55 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:37:13 +0100 Subject: [PATCH 06/61] Handle different input formats --- NAMESPACE | 1 + R/elev.R | 40 +++++++++++++++++--------------------- tests/testthat/test-elev.R | 32 +++++++++++++++--------------- 3 files changed, 35 insertions(+), 38 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 9a5661f..3e45b0d 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -35,6 +35,7 @@ importFrom(randomForest,varImpPlot) importFrom(sf,as_Spatial) importFrom(sf,st_as_sf) importFrom(sf,st_bbox) +importFrom(sf,st_crs) importFrom(sf,st_geometry) importFrom(sf,st_is_longlat) importFrom(sp,SpatialPointsDataFrame) diff --git a/R/elev.R b/R/elev.R index 2442268..1d43e39 100644 --- a/R/elev.R +++ b/R/elev.R @@ -118,7 +118,7 @@ #' } #' @importFrom elevatr get_elev_raster #' @importFrom geodata elevation_3s -#' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat +#' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs #' @importFrom terra rast extract xyFromCell mosaic writeRaster rast #' @export elev <- function(output_dir, location, e_source = "mapzen") { @@ -128,30 +128,26 @@ elev <- function(output_dir, location, e_source = "mapzen") { stop("e_source must be \"mapzen\" or \"geodata\"") } - # Convert to "sfc_POLYGON" "sfc" if ("sfg" %in% class(location)) { - location <- sf::st_geometry(location) - } - - # Convert sf locations to SP - if (("sf" %in% class(location)) || ("sfc" %in% class(location))) { - location <- sf::as_Spatial(location) + location <- as(location, "Spatial") } + location_sf <- as(location, "sf") # Check that the bounding box coordinates - if (!sum( - sf::st_bbox(location)[c(1)] >= -180, - sf::st_bbox(location)[c(2)] >= -90, - sf::st_bbox(location)[c(3)] <= 180, - sf::st_bbox(location)[c(4)] <= 90 - ) == 4) stop( - "bounding box of location has potentially an invalid value range" - ) + bbox <- sf::st_bbox(location_sf) + if (bbox[["xmin"]] < -180 | bbox[["xmax"]] > 180) { + stop("`location` bounding box falls outside supported longitudes ", + "-180 to 180") + } + if (bbox[["ymin"]] < -90 | bbox[["ymax"]] > 90) { + stop("`location` bounding box falls outside supported latitudes ", + "-90 to 90") + } - if (is.na(sf::st_is_longlat(location)) || - !sf::st_is_longlat(location) == TRUE) stop( - "check that the location has been projected (epsg: 4326)" - ) + if (!isTRUE(sf::st_is_longlat(location_sf))) { + warning("Coordinate reference system not specified; assuming EPSG:4326") + st_crs(location_sf) <- "EPSG:4326" + } # Create elev folder if (!dir.exists(paste0(output_dir, "/elev"))) { @@ -164,7 +160,7 @@ elev <- function(output_dir, location, e_source = "mapzen") { { # mapzen srtm_mosaic <- terra::rast( elevatr::get_elev_raster( - location, z = 7, override_size_check = TRUE, + location_sf, z = 7, override_size_check = TRUE, progress = FALSE ) ) @@ -173,7 +169,7 @@ elev <- function(output_dir, location, e_source = "mapzen") { overwrite = TRUE) }, { # geodata - srtm_mosaic <- .elev_geodata(location, output_dir) + srtm_mosaic <- .elev_geodata(location_sf, output_dir) file_path <- paste0(output_dir, "/elev/srtm.tif") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 325d886..1a8b3af 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -5,42 +5,42 @@ test_that("elev() fails gracefully", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) + # No data available in the oceans sea <- sf::st_as_sf( data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) - # elev(tmp_dir, tile50) expect_warning( expect_error(elev(tmp_dir, sea, "GEOdata"), "No data downloaded"), "Could not download srtm_12_24" ) + # This is testing R's functionality, rather than our packages, so does + # not need to be included in this package's test suite; + # we do not handle the case where no parameters are specified. expect_error( expect_warning( elev(), "Error in elev() : argument location is missing, with no default" )) - flip_lat_long <- sf::st_polygon( - list(cbind(lat = c(-61, -49, -61, -61), lng = c(161, 161, 154, 161)))) - + flip_lat_long <- sf::st_polygon(list(cbind( + lat = c(-61, -49, -61, -61), + lng = c(161, 161, 154, 161) + ))) expect_error( - expect_warning( - elev(location = flip_lat_long), - "Error in elev(location = flip_lat_long) : - bounding box of location has potentially an invalid value range" - )) + elev(location = flip_lat_long), + "bounding box falls outside supported latitudes" + ) - flip_lat_long <- sf::st_polygon( + unprojected <- sf::st_polygon( list(cbind(long = c(161, 161, 154, 161), lat = c(-61, -49, -61, -61))) ) - - expect_error( - expect_warning( - elev(location = flip_lat_long), - "Error: check that the location has been projected (epsg: 4326)" - )) + expect_warning( + elev(tmp_dir, location = unprojected), + "Coordinate reference system not specified" + ) }) From 93e8370f86d34e3891effa5e34535128920aa30a Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:39:22 +0100 Subject: [PATCH 07/61] <- --- NAMESPACE | 2 +- R/elev.R | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 3e45b0d..5976ee5 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -32,10 +32,10 @@ importFrom(plyr,round_any) importFrom(randomForest,importance) importFrom(randomForest,randomForest) importFrom(randomForest,varImpPlot) +importFrom(sf,"st_crs<-") importFrom(sf,as_Spatial) importFrom(sf,st_as_sf) importFrom(sf,st_bbox) -importFrom(sf,st_crs) importFrom(sf,st_geometry) importFrom(sf,st_is_longlat) importFrom(sp,SpatialPointsDataFrame) diff --git a/R/elev.R b/R/elev.R index 1d43e39..a3e2673 100644 --- a/R/elev.R +++ b/R/elev.R @@ -118,7 +118,7 @@ #' } #' @importFrom elevatr get_elev_raster #' @importFrom geodata elevation_3s -#' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs +#' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- #' @importFrom terra rast extract xyFromCell mosaic writeRaster rast #' @export elev <- function(output_dir, location, e_source = "mapzen") { From a96ece67a57cc8ea12ebc33fc1d39029bcd570c0 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 19:57:48 +0100 Subject: [PATCH 08/61] expect_snapshots --- DESCRIPTION | 1 + R/elev.R | 3 ++- tests/testthat/_snaps/elev.md | 21 +++++++++++++++++++++ tests/testthat/test-elev.R | 27 ++++++++------------------- 4 files changed, 32 insertions(+), 20 deletions(-) create mode 100644 tests/testthat/_snaps/elev.md diff --git a/DESCRIPTION b/DESCRIPTION index ffd781a..4b1b93a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -60,5 +60,6 @@ Suggests: Config/Needs/check: rcmdcheck Config/Needs/coverage: covr Config/Needs/website: pkgdown +Config/testthat/edition: 3 RoxygenNote: 7.2.3 Roxygen: list(markdown = TRUE) diff --git a/R/elev.R b/R/elev.R index a3e2673..5834020 100644 --- a/R/elev.R +++ b/R/elev.R @@ -43,7 +43,7 @@ -1 } } - if (!error) { + if (error == 0) { tryCatch(utils::unzip(temp_file, paste0(id, ".tif"), exdir = output_dir), error = function(e) warning("Failed to unzip: ", id)) rs <- rast(tif) @@ -146,6 +146,7 @@ elev <- function(output_dir, location, e_source = "mapzen") { if (!isTRUE(sf::st_is_longlat(location_sf))) { warning("Coordinate reference system not specified; assuming EPSG:4326") + # TODO JS to check: Should we prefer WGS84 to match output? st_crs(location_sf) <- "EPSG:4326" } diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md new file mode 100644 index 0000000..74fc379 --- /dev/null +++ b/tests/testthat/_snaps/elev.md @@ -0,0 +1,21 @@ +# elev() fails gracefully + + Code + elev(tmp_dir, sea, "GEOdata") + Warning + Coordinate reference system not specified; assuming EPSG:4326 + Could not download srtm_12_24: HTTP status 404 + Error + No data downloaded. + +# elev() + + Code + geoElev <- elev(tmp_dir, island, "GEOdata") + Warning + Coordinate reference system not specified; assuming EPSG:4326 + Could not download srtm_69_22: HTTP status 404 + Could not download srtm_69_23: HTTP status 404 + Could not download srtm_67_24: HTTP status 404 + Could not download srtm_69_24: HTTP status 404 + diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 1a8b3af..79d8da2 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -10,10 +10,7 @@ test_that("elev() fails gracefully", { sea <- sf::st_as_sf( data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) - expect_warning( - expect_error(elev(tmp_dir, sea, "GEOdata"), "No data downloaded"), - "Could not download srtm_12_24" - ) + expect_snapshot(elev(tmp_dir, sea, "GEOdata"), cran = TRUE, error = TRUE) # This is testing R's functionality, rather than our packages, so does # not need to be included in this package's test suite; @@ -33,15 +30,6 @@ test_that("elev() fails gracefully", { "bounding box falls outside supported latitudes" ) - unprojected <- sf::st_polygon( - list(cbind(long = c(161, 161, 154, 161), - lat = c(-61, -49, -61, -61))) - ) - expect_warning( - elev(tmp_dir, location = unprojected), - "Coordinate reference system not specified" - ) - }) test_that("elev()", { @@ -60,14 +48,15 @@ test_that("elev()", { # In progress: the below will replace the above. island <- sf::st_polygon( - list(cbind(lat = c(-61, -49, -61, -61), lng = c(161, 161, 154, 161)))) + list(cbind(lng = c(161, 161, 154, 161), lat = c(-61, -49, -61, -61)))) # This polygon covers a tile that does not contain a vertex. - # Should this tile be downloaded too? + # This tile should be downloaded too - # elev(tmp_dir, island) - expect_warning( - geoElev <- elev(tmp_dir, island, "GEOdata"), - "Could not download srtm_69_22") + expect_snapshot(geoElev <- elev(tmp_dir, island, "GEOdata"), + cran = TRUE) + # Expect the warnings: + # "Coordinate reference system not specified", + # "Could not download srtm_6._2." skip_if_not_installed("vdiffr") library("terra") From acef36cc5e2146163c4f015ca36999258527143c Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:07:13 +0100 Subject: [PATCH 09/61] importFrom methods as --- NAMESPACE | 1 + R/elev.R | 1 + 2 files changed, 2 insertions(+) diff --git a/NAMESPACE b/NAMESPACE index 5976ee5..7b58ac7 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -28,6 +28,7 @@ importFrom(graphics,points) importFrom(graphics,strwidth) importFrom(graphics,text) importFrom(macroBiome,cliHoldridgePoints) +importFrom(methods,as) importFrom(plyr,round_any) importFrom(randomForest,importance) importFrom(randomForest,randomForest) diff --git a/R/elev.R b/R/elev.R index 5834020..8a4678e 100644 --- a/R/elev.R +++ b/R/elev.R @@ -118,6 +118,7 @@ #' } #' @importFrom elevatr get_elev_raster #' @importFrom geodata elevation_3s +#' @importFrom methods as #' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- #' @importFrom terra rast extract xyFromCell mosaic writeRaster rast #' @export From 7137ab249ef9a369dec621c1e01da82c84dd2aa8 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:09:04 +0100 Subject: [PATCH 10/61] Order reversed in testthat 3 --- tests/testthat/test-worldclim.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-worldclim.R b/tests/testthat/test-worldclim.R index 2c74ed8..3d7b6e8 100644 --- a/tests/testthat/test-worldclim.R +++ b/tests/testthat/test-worldclim.R @@ -9,9 +9,10 @@ test_that("worldclim() fails gracefully", { lng = c(-156, -156, -157, -156)), coords = 1:2) tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - expect_null(expect_warning( - worldclim(out = tmp_dir, loc = flip_lat_long, var = "prec"), - "Could not map all coordinates to tiles")) + expect_warning( + expect_null(worldclim(out = tmp_dir, loc = flip_lat_long, var = "prec")), + "Could not map all coordinates to tiles" + ) }) test_that("worldclim() downloads data", { From 4b8da73568f82bd28df64cb37e2bebd03fce22ea Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:12:08 +0100 Subject: [PATCH 11/61] lint --- R/elev.R | 10 +++++----- tests/testthat/_snaps/elev.md | 2 +- tests/testthat/test-elev.R | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/R/elev.R b/R/elev.R index 8a4678e..29184cc 100644 --- a/R/elev.R +++ b/R/elev.R @@ -28,8 +28,8 @@ "https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/", id, ".zip" ) - urlStatus <- attr(curlGetHeaders(zip), "status") - error <- if (urlStatus == 200) { + url_status <- attr(curlGetHeaders(zip), "status") + error <- if (url_status == 200) { tryCatch( utils::download.file(url = zip, destfile = temp_file, mode = "wb", ...), # Returns 0 on success @@ -39,7 +39,7 @@ } ) } else { - warning("Could not download ", id, ": HTTP status ", urlStatus) + warning("Could not download ", id, ": HTTP status ", url_status) -1 } } @@ -136,11 +136,11 @@ elev <- function(output_dir, location, e_source = "mapzen") { # Check that the bounding box coordinates bbox <- sf::st_bbox(location_sf) - if (bbox[["xmin"]] < -180 | bbox[["xmax"]] > 180) { + if (bbox[["xmin"]] < -180 || bbox[["xmax"]] > 180) { stop("`location` bounding box falls outside supported longitudes ", "-180 to 180") } - if (bbox[["ymin"]] < -90 | bbox[["ymax"]] > 90) { + if (bbox[["ymin"]] < -90 || bbox[["ymax"]] > 90) { stop("`location` bounding box falls outside supported latitudes ", "-90 to 90") } diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md index 74fc379..6601658 100644 --- a/tests/testthat/_snaps/elev.md +++ b/tests/testthat/_snaps/elev.md @@ -11,7 +11,7 @@ # elev() Code - geoElev <- elev(tmp_dir, island, "GEOdata") + geo_elev <- elev(tmp_dir, island, "GEOdata") Warning Coordinate reference system not specified; assuming EPSG:4326 Could not download srtm_69_22: HTTP status 404 diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 79d8da2..f2450e9 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -52,7 +52,7 @@ test_that("elev()", { # This polygon covers a tile that does not contain a vertex. # This tile should be downloaded too - expect_snapshot(geoElev <- elev(tmp_dir, island, "GEOdata"), + expect_snapshot(geo_elev <- elev(tmp_dir, island, "GEOdata"), cran = TRUE) # Expect the warnings: # "Coordinate reference system not specified", @@ -60,5 +60,5 @@ test_that("elev()", { skip_if_not_installed("vdiffr") library("terra") - vdiffr::expect_doppelganger("geo-elev", function() plot(geoElev)) + vdiffr::expect_doppelganger("geo-elev", function() plot(geo_elev)) }) From 05619070a1b398eb07aa5473f254a963f20ef940 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:16:13 +0100 Subject: [PATCH 12/61] rm duplicate --- tests/testthat/test-elev.R | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f2450e9..c6f62d1 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -41,12 +41,6 @@ test_that("elev()", { # Longitude east: 155-160 # We should be able to download these squares even if our target area # overlaps non-existent neighbouring squares - - island <- sf::st_as_sf( - data.frame(lat = c(-61, -59, -51, -49, -61, -61), - lng = c(161, 159, 159, 161, 154, 161)), coords = 2:1) - - # In progress: the below will replace the above. island <- sf::st_polygon( list(cbind(lng = c(161, 161, 154, 161), lat = c(-61, -49, -61, -61)))) # This polygon covers a tile that does not contain a vertex. From d818c91c660895484c22a3b4998546915a08c189 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 20:18:07 +0100 Subject: [PATCH 13/61] import methods --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 4b1b93a..9d21872 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -43,6 +43,7 @@ Imports: geodata, glue, macroBiome, + methods, plyr, randomForest, sf, From 08cc69d0624438dd8cbad48ee4f50cb1ba002625 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 21:37:53 +0100 Subject: [PATCH 14/61] Pass `...` to `download.file()` Masks write to console --- R/elev.R | 5 +++-- R/worldclim.R | 4 ++-- man/elev.Rd | 4 +++- man/worldclim.Rd | 4 ++-- tests/testthat/_snaps/elev.md | 2 +- tests/testthat/test-elev.R | 3 +-- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/R/elev.R b/R/elev.R index 29184cc..15b205f 100644 --- a/R/elev.R +++ b/R/elev.R @@ -79,6 +79,7 @@ #' @template output_dir_param #' @template output_location_param #' @template output_e_source_param +#' @param \dots Additional arguments to [`download.file()`]. #' #' @return #' Creates one subfolder named elev storing a raster (.tiff). If elevation is @@ -122,7 +123,7 @@ #' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- #' @importFrom terra rast extract xyFromCell mosaic writeRaster rast #' @export -elev <- function(output_dir, location, e_source = "mapzen") { +elev <- function(output_dir, location, e_source = "mapzen", ...) { e_source_id <- pmatch(tolower(e_source[1]), c("mapzen", "geodata")) if (is.na(e_source_id)) { @@ -171,7 +172,7 @@ elev <- function(output_dir, location, e_source = "mapzen") { overwrite = TRUE) }, { # geodata - srtm_mosaic <- .elev_geodata(location_sf, output_dir) + srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) file_path <- paste0(output_dir, "/elev/srtm.tif") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) diff --git a/R/worldclim.R b/R/worldclim.R index a961328..ef4e338 100644 --- a/R/worldclim.R +++ b/R/worldclim.R @@ -57,8 +57,8 @@ #' #' @template output_dir_param #' @template output_location_param -#' @param var,\dots Arguments to control a download from the Internet -#' `download.file()`. +#' @param var,\dots Arguments to [`download.file()`] to control file download. +#' . #' #' @return #' `worldclim()` is called for its side effects and returns `NULL`. diff --git a/man/elev.Rd b/man/elev.Rd index f470d1a..adbd98a 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -4,7 +4,7 @@ \alias{elev} \title{Download elevation data} \usage{ -elev(output_dir, location, e_source = "mapzen") +elev(output_dir, location, e_source = "mapzen", ...) } \arguments{ \item{output_dir}{Character (e.g., \code{"../Desktop/chelsa"}). Pathway to where @@ -16,6 +16,8 @@ objects.} \item{e_source}{Character (e.g., \code{mapzen} or \code{WorldClim}). Indicating the elevation data source.} + +\item{\dots}{Additional arguments to \code{\link[=download.file]{download.file()}}.} } \value{ Creates one subfolder named elev storing a raster (.tiff). If elevation is diff --git a/man/worldclim.Rd b/man/worldclim.Rd index cf64fd6..7be9769 100644 --- a/man/worldclim.Rd +++ b/man/worldclim.Rd @@ -14,8 +14,8 @@ the data will be stored.} \link[sf:st]{sf::st_polygon} to make polygons and \link[sf:st_as_sf]{sf::st_as_sf} to make point objects.} -\item{var, \dots}{Arguments to control a download from the Internet -\code{download.file()}.} +\item{var, \dots}{Arguments to \code{\link[=download.file]{download.file()}} to control file download. +.} } \value{ \code{worldclim()} is called for its side effects and returns \code{NULL}. diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md index 6601658..973cae0 100644 --- a/tests/testthat/_snaps/elev.md +++ b/tests/testthat/_snaps/elev.md @@ -11,7 +11,7 @@ # elev() Code - geo_elev <- elev(tmp_dir, island, "GEOdata") + geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE) Warning Coordinate reference system not specified; assuming EPSG:4326 Could not download srtm_69_22: HTTP status 404 diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index c6f62d1..f9267ff 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -46,13 +46,12 @@ test_that("elev()", { # This polygon covers a tile that does not contain a vertex. # This tile should be downloaded too - expect_snapshot(geo_elev <- elev(tmp_dir, island, "GEOdata"), + expect_snapshot(geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), cran = TRUE) # Expect the warnings: # "Coordinate reference system not specified", # "Could not download srtm_6._2." skip_if_not_installed("vdiffr") - library("terra") vdiffr::expect_doppelganger("geo-elev", function() plot(geo_elev)) }) From 69ebe3b60f3f31998ece0f34acadd96c19d9d711 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 21:38:54 +0100 Subject: [PATCH 15/61] Suppress messages --- tests/testthat/test-worldclim.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-worldclim.R b/tests/testthat/test-worldclim.R index 3d7b6e8..46df121 100644 --- a/tests/testthat/test-worldclim.R +++ b/tests/testthat/test-worldclim.R @@ -31,7 +31,7 @@ test_that("worldclim() downloads data", { lng = c(-123, -124, -123, -123)), coords = 2:1) # Obtain raster files - worldclim(out = tmp_dir, loc = tile50, var = "prec") + worldclim(out = tmp_dir, loc = tile50, var = "prec", quiet = TRUE) tile_files <- paste0(tmp_dir, "/prec/wc2.1_30s_prec_", formatC(1:12, width = 2, flag = "0"), ".tif") expect_equal(file.exists(tile_files), rep(TRUE, 12)) @@ -59,7 +59,7 @@ test_that("worldclim() downloads data", { lng = c(-123, -174, -123, -123)), coords = 2:1) # Obtain raster data - worldclim(out = tmp_dir, loc = south, var = "elev") + worldclim(out = tmp_dir, loc = south, var = "elev", quiet = TRUE) south_file <- paste0(tmp_dir, "/elev/wc2.1_30s_elev_01.tif") expect_true(file.exists(south_file)) From d43d4ca955ef7738c94b438bd89ba40ad6e4ded9 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 21:54:08 +0100 Subject: [PATCH 16/61] terra::plot --- tests/testthat/test-elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f9267ff..64b898f 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -53,5 +53,5 @@ test_that("elev()", { # "Could not download srtm_6._2." skip_if_not_installed("vdiffr") - vdiffr::expect_doppelganger("geo-elev", function() plot(geo_elev)) + vdiffr::expect_doppelganger("geo-elev", function() terra::plot(geo_elev)) }) From 283c46cb3f08a702918d8651bb098bbd40df9459 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:07:36 +0100 Subject: [PATCH 17/61] quiet=T Consistency of snapshot --- tests/testthat/test-elev.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 64b898f..fc96053 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -10,7 +10,8 @@ test_that("elev() fails gracefully", { sea <- sf::st_as_sf( data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) - expect_snapshot(elev(tmp_dir, sea, "GEOdata"), cran = TRUE, error = TRUE) + expect_snapshot(elev(tmp_dir, sea, "GEOdata", quiet = TRUE), + cran = TRUE, error = TRUE) # This is testing R's functionality, rather than our packages, so does # not need to be included in this package's test suite; From e0e602a0f3237cc090e849c270a7319fb5e34cb8 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:13:24 +0100 Subject: [PATCH 18/61] rm geodata import --- NAMESPACE | 1 - R/elev.R | 3 +-- man/elev.Rd | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index 7b58ac7..c9e525a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,7 +18,6 @@ importFrom(dplyr,group_by) importFrom(dplyr,summarize) importFrom(elevatr,get_elev_raster) importFrom(exactextractr,exact_extract) -importFrom(geodata,elevation_3s) importFrom(geodata,worldclim_tile) importFrom(glue,glue) importFrom(graphics,axis) diff --git a/R/elev.R b/R/elev.R index 15b205f..139626b 100644 --- a/R/elev.R +++ b/R/elev.R @@ -73,7 +73,7 @@ #' #' @description #' `elev()` downloads elevation data the Shuttle Radar Topography Mission -#' (SRTM) , specifically the hole-filled CGIAR-SRTM (90 m resolution) for +#' (SRTM), specifically the hole-filled CGIAR-SRTM (90 m resolution) for #' latitudes between -60 and 60 or Mapzen's synthesis digital elevation product. #' #' @template output_dir_param @@ -118,7 +118,6 @@ #' elev(output_dir = "...Desktop/elev", location = italy_py) #' } #' @importFrom elevatr get_elev_raster -#' @importFrom geodata elevation_3s #' @importFrom methods as #' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- #' @importFrom terra rast extract xyFromCell mosaic writeRaster rast diff --git a/man/elev.Rd b/man/elev.Rd index adbd98a..afffc21 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -32,7 +32,7 @@ to 611.5 m ground resolution at 60° latitude 864.8 m at 45° and 1223 m at 0°. } \description{ \code{elev()} downloads elevation data the Shuttle Radar Topography Mission -(SRTM) , specifically the hole-filled CGIAR-SRTM (90 m resolution) for +(SRTM), specifically the hole-filled CGIAR-SRTM (90 m resolution) for latitudes between -60 and 60 or Mapzen's synthesis digital elevation product. } \examples{ From da5afae817c851a74b8140320cdfe53372a9e4ea Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:16:16 +0100 Subject: [PATCH 19/61] instructive param name --- R/elev.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/elev.R b/R/elev.R index 139626b..0dbe389 100644 --- a/R/elev.R +++ b/R/elev.R @@ -24,14 +24,14 @@ error <- if (file.exists(tif)) { 0 } else { - zip <- paste0( + zip_url <- paste0( "https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/", id, ".zip" ) - url_status <- attr(curlGetHeaders(zip), "status") + url_status <- attr(curlGetHeaders(zip_url), "status") error <- if (url_status == 200) { tryCatch( - utils::download.file(url = zip, destfile = temp_file, mode = "wb", + utils::download.file(url = zip_url, destfile = temp_file, mode = "wb", ...), # Returns 0 on success error = function(e) { warning("Failed to download ", id, ": ", e) From 9765bf4f2365de5ac85ccb8cb08b0c80c2dcfbc5 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:20:21 +0100 Subject: [PATCH 20/61] No need to verify ssl --- R/elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/elev.R b/R/elev.R index 0dbe389..00b84ff 100644 --- a/R/elev.R +++ b/R/elev.R @@ -28,7 +28,7 @@ "https://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/", id, ".zip" ) - url_status <- attr(curlGetHeaders(zip_url), "status") + url_status <- attr(curlGetHeaders(zip_url, verify = FALSE), "status") error <- if (url_status == 200) { tryCatch( utils::download.file(url = zip_url, destfile = temp_file, mode = "wb", From c8998381f500217334764c07da2119af4b089c6d Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:45:01 +0100 Subject: [PATCH 21/61] scrub_progress_bars --- tests/testthat/_snaps/elev.md | 2 +- tests/testthat/test-elev.R | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md index 973cae0..833b4da 100644 --- a/tests/testthat/_snaps/elev.md +++ b/tests/testthat/_snaps/elev.md @@ -1,7 +1,7 @@ # elev() fails gracefully Code - elev(tmp_dir, sea, "GEOdata") + elev(tmp_dir, sea, "GEOdata", quiet = TRUE) Warning Coordinate reference system not specified; assuming EPSG:4326 Could not download srtm_12_24: HTTP status 404 diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index fc96053..3d9217c 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -1,3 +1,12 @@ +scrub_progress_bars <- function(x) { + progress_bars <- grep("^[\\|\\-=\\s]+$", x, perl = TRUE) + if (length(progress_bars)) { + x[-progress_bars] + } else { + x + } +} + test_that("elev() fails gracefully", { expect_error(elev(out = "", location = "", e_source = ""), @@ -11,7 +20,7 @@ test_that("elev() fails gracefully", { data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) expect_snapshot(elev(tmp_dir, sea, "GEOdata", quiet = TRUE), - cran = TRUE, error = TRUE) + cran = TRUE, error = TRUE, scrub_progress_bars) # This is testing R's functionality, rather than our packages, so does # not need to be included in this package's test suite; @@ -48,7 +57,7 @@ test_that("elev()", { # This tile should be downloaded too expect_snapshot(geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), - cran = TRUE) + cran = TRUE, error = FALSE, scrub_progress_bars) # Expect the warnings: # "Coordinate reference system not specified", # "Could not download srtm_6._2." From 4c74b5f2d4cf486e54a23cfda02b998e8fb1dd41 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Tue, 11 Jul 2023 22:50:46 +0100 Subject: [PATCH 22/61] blank lines too --- tests/testthat/test-elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 3d9217c..996225a 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -1,5 +1,5 @@ scrub_progress_bars <- function(x) { - progress_bars <- grep("^[\\|\\-=\\s]+$", x, perl = TRUE) + progress_bars <- grep("^[\\|\\-=\\s]*$", x, perl = TRUE) if (length(progress_bars)) { x[-progress_bars] } else { From eb3a07ba2bab9cc6cea31b9dcecad95d4593efa6 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 07:40:34 +0100 Subject: [PATCH 23/61] use expect_warning Handles progress bars --- tests/testthat/_snaps/elev.md | 12 ------------ tests/testthat/test-elev.R | 15 +++++++++++++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md index 833b4da..4798e46 100644 --- a/tests/testthat/_snaps/elev.md +++ b/tests/testthat/_snaps/elev.md @@ -7,15 +7,3 @@ Could not download srtm_12_24: HTTP status 404 Error No data downloaded. - -# elev() - - Code - geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE) - Warning - Coordinate reference system not specified; assuming EPSG:4326 - Could not download srtm_69_22: HTTP status 404 - Could not download srtm_69_23: HTTP status 404 - Could not download srtm_67_24: HTTP status 404 - Could not download srtm_69_24: HTTP status 404 - diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 996225a..6468f25 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -56,8 +56,19 @@ test_that("elev()", { # This polygon covers a tile that does not contain a vertex. # This tile should be downloaded too - expect_snapshot(geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), - cran = TRUE, error = FALSE, scrub_progress_bars) + expect_warning( + expect_warning( + expect_warning( + expect_warning( + expect_warning( + geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), + "Could not download srtm_6._2."), + "Could not download srtm_6._2."), + "Could not download srtm_6._2."), + "Could not download srtm_6._2."), + "Coordinate reference system not specified") + + #cran = TRUE, error = FALSE, scrub_progress_bars) # Expect the warnings: # "Coordinate reference system not specified", # "Could not download srtm_6._2." From e0bd8c85a6946cff833f37a27de5f2fc932592e1 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 07:55:36 +0100 Subject: [PATCH 24/61] Skip if server offline --- tests/testthat/test-elev.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 6468f25..370ddd4 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -43,6 +43,15 @@ test_that("elev() fails gracefully", { }) test_that("elev()", { + tryCatch( + curlGetHeaders("srtm.csi.cgiar.org", timeout = 1), + error = function(e) { + if (length(grep("Connection timed out", e$message, fixed = TRUE))) { + skip("Could not connect to srtm.csi.cgiar.org?") + } + } + ) + tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) From e382e2369740784048f7d4b7389cd145f3042b63 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 07:57:50 +0100 Subject: [PATCH 25/61] Skip if srtm.csi.cgiar.org offline --- tests/testthat/test-elev.R | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 370ddd4..f2e6afb 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -7,6 +7,17 @@ scrub_progress_bars <- function(x) { } } +skip_if_server_offline <- function(server) { + tryCatch( + curlGetHeaders(server, timeout = 1), + error = function(e) { + if (length(grep("Connection timed out", e$message, fixed = TRUE))) { + skip(paste("Could not connect to", server)) + } + } + ) +} + test_that("elev() fails gracefully", { expect_error(elev(out = "", location = "", e_source = ""), @@ -15,13 +26,6 @@ test_that("elev() fails gracefully", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # No data available in the oceans - sea <- sf::st_as_sf( - data.frame(lat = c(-59, -59, -58, -59), - lng = c(-123, -124, -123, -123)), coords = 2:1) - expect_snapshot(elev(tmp_dir, sea, "GEOdata", quiet = TRUE), - cran = TRUE, error = TRUE, scrub_progress_bars) - # This is testing R's functionality, rather than our packages, so does # not need to be included in this package's test suite; # we do not handle the case where no parameters are specified. @@ -40,17 +44,18 @@ test_that("elev() fails gracefully", { "bounding box falls outside supported latitudes" ) + skip_if_server_offline("srtm.csi.cgiar.org") + # No data available in the oceans + sea <- sf::st_as_sf( + data.frame(lat = c(-59, -59, -58, -59), + lng = c(-123, -124, -123, -123)), coords = 2:1) + expect_snapshot(elev(tmp_dir, sea, "GEOdata", quiet = TRUE), + cran = TRUE, error = TRUE, scrub_progress_bars) + }) test_that("elev()", { - tryCatch( - curlGetHeaders("srtm.csi.cgiar.org", timeout = 1), - error = function(e) { - if (length(grep("Connection timed out", e$message, fixed = TRUE))) { - skip("Could not connect to srtm.csi.cgiar.org?") - } - } - ) + skip_if_server_offline("srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) From 8d02326aeba788809d22866a209f28fab4535047 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 07:59:43 +0100 Subject: [PATCH 26/61] Don't attach; called with :: --- tests/testthat/test-plot.R | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tests/testthat/test-plot.R b/tests/testthat/test-plot.R index 9432584..06046a6 100644 --- a/tests/testthat/test-plot.R +++ b/tests/testthat/test-plot.R @@ -11,10 +11,6 @@ test_that("plot_XX() fails gracefully", { }) test_that("ce_plot() works", { - - library("terra") - library("sf") - # Set testing data #### # Create temporary file to supply to the ce_extract From 072a85731e01b4cf082ccbe9b3b8542d82a09129 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:01:54 +0100 Subject: [PATCH 27/61] Explain why not skip_if_offline --- tests/testthat/test-elev.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f2e6afb..88280ac 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -8,6 +8,8 @@ scrub_progress_bars <- function(x) { } skip_if_server_offline <- function(server) { + # Preferred to testthat::skip_if_offline as this runs on CRAN + # Thus we can expect notice of any breaking changes to imported packages tryCatch( curlGetHeaders(server, timeout = 1), error = function(e) { From 1c8cfef710695e0c6e9f740871bd2d4adccc3a9a Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:04:13 +0100 Subject: [PATCH 28/61] testthat:: for lint --- tests/testthat/test-elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 88280ac..4c1a834 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -14,7 +14,7 @@ skip_if_server_offline <- function(server) { curlGetHeaders(server, timeout = 1), error = function(e) { if (length(grep("Connection timed out", e$message, fixed = TRUE))) { - skip(paste("Could not connect to", server)) + testthat::skip(paste("Could not connect to", server)) } } ) From b8473b5822c2fb726f0c5fe4af64b16aab6750f8 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:13:08 +0100 Subject: [PATCH 29/61] Squashed commit of the following: commit 54078418a2fb658460110b7ce413a6c22999e0da Author: James Tsakalos Date: Tue Jul 11 15:16:55 2023 +0200 corrections to remove srtm cells that are located in the ocean, new polygon example commit d16a22c7e2dcb10b76776cf393f89e164d7e2963 Author: James Tsakalos Date: Tue Jul 11 15:16:16 2023 +0200 correcting the args in e_source. commit e51e4ed290e2fcaf0840c8340d3f000df9845bf7 Author: James Tsakalos Date: Tue Jul 11 15:16:01 2023 +0200 adding links for how to make polygon and point data. adding polygon example. commit fd9bcb166d1fef16896dfc42870378e5512998d4 Author: James Tsakalos Date: Tue Jul 11 15:14:59 2023 +0200 correcting documentation for ce_download() commit 0528aa3484195575bb317bdee1ce4b65a9607ba0 Author: James Tsakalos Date: Tue Jul 11 15:14:40 2023 +0200 adding elev() testing for points and polygons. commit 20ffa94014a6e73d08cd7711d333d84d42cacc6b Author: James Tsakalos Date: Tue Jul 11 15:14:02 2023 +0200 adding srtm tiles - previous version allowed for tiles in the ocean, resulting in nulls commit df7803d4e739fad12675185a5c2cd8701115f48a Author: James Tsakalos Date: Tue Jul 11 15:13:19 2023 +0200 namespace for rasterize --- R/data_srtm_tiles.R | 15 +++ R/elev.R | 39 +++++++- data/srtm_tiles.rda | Bin 0 -> 17088 bytes man-roxygen/output_e_source_param.R | 2 +- man/ce_download.Rd | 2 +- man/elev.Rd | 29 +++++- man/srtm_tiles.Rd | 25 +++++ tests/testthat/expected/mapzen.tif | Bin 0 -> 11372 bytes tests/testthat/expected/mapzen_pt.tif | Bin 0 -> 980 bytes tests/testthat/expected/srtm.tif | Bin 0 -> 4886 bytes tests/testthat/expected/srtm_pt.tif | Bin 0 -> 2242 bytes tests/testthat/test-elev.R | 132 ++++++++++++++++++++++++++ 12 files changed, 234 insertions(+), 10 deletions(-) create mode 100644 R/data_srtm_tiles.R create mode 100644 data/srtm_tiles.rda create mode 100644 man/srtm_tiles.Rd create mode 100644 tests/testthat/expected/mapzen.tif create mode 100644 tests/testthat/expected/mapzen_pt.tif create mode 100644 tests/testthat/expected/srtm.tif create mode 100644 tests/testthat/expected/srtm_pt.tif diff --git a/R/data_srtm_tiles.R b/R/data_srtm_tiles.R new file mode 100644 index 0000000..5b19ab4 --- /dev/null +++ b/R/data_srtm_tiles.R @@ -0,0 +1,15 @@ +##' STRM tiles data +##' +##' SRTM tiles data. +##' +##' @docType data +##' @format{ An object of class \code{SpatialPolygonsDataFrame} with 872 rows +##' and 1 columns.} +##' @details Contains tiles to assist downloading from 'geodata'. +##' @encoding UTF-8 +##' @keywords datasets +##' @rdname srtm_tiles +##' @examples +##' data("srtm_tiles", package = "climenv") +##' head(srtm_tiles) +"srtm_tiles" diff --git a/R/elev.R b/R/elev.R index 00b84ff..245ee18 100644 --- a/R/elev.R +++ b/R/elev.R @@ -5,11 +5,17 @@ y_min <- -60 # create SRTM tiles rs <- terra::rast(res = 5, ymin = y_min, ymax = y_max) - rs[] <- seq_len(prod(dim(rs))) + rs <- terra::rasterize(terra::vect(climenv::srtm_tiles), rs, "FID") + + # we need to set the crs of the SRTM tiles + terra::crs(rs) <- "epsg:4326" + + # the location crs needs to match the tiles + location <- terra::project(terra::vect(location), rs) # Intersect location and tiles tiles <- unique( - terra::extract(rs, terra::vect(location), touches = TRUE)$lyr.1 + terra::extract(rs, location, touches = TRUE)$FID ) cols <- formatC(colFromCell(rs, tiles), width = 2, flag = 0) rows <- formatC(rowFromCell(rs, tiles), width = 2, flag = 0) @@ -94,7 +100,8 @@ #' #' @author James L. Tsakalos #' @seealso A more convenient function for other climate and elevation data -#' [`ce_download()`]. +#' [`ce_download()`]. See [sf::st_polygon] to make polygons and [sf::st_as_sf] +#' to make point objects. #' @references{ Hijmans, R.J., Barbosa, M., Ghosh, A., & Mandel, A. (2023). #' geodata: Download Geographic Data. R package version 0.5-8. #' https://CRAN.R-project.org/package=geodata @@ -112,15 +119,37 @@ #' #' @examples #' \dontrun{ -#' # Start by loading Italy's Biom data +#' # We could do this using Italy's Biome data #' data("italy_py", package = "climenv") #' # elevation will be saved in the output_dir (i.e. output directory) #' elev(output_dir = "...Desktop/elev", location = italy_py) #' } +#' +#' Or a smaller example we can make a polygon covering an island in the ocean. +#' +#' location <- sf::st_polygon( +#' list( +#' cbind( +#' long = c(161, 161, 154, 161), +#' lat = c(-61, -49, -61, -61) +#' ) +#' ) +#' ) +#' +#' # We need to make sure that the polygon the correct class +#' location <- sf::st_geometry(location) +#' class(location) # "sfc_POLYGON" "sfc" +#' +#' # Lets make sure to set the coordinate reference system +#' sf::st_crs(location) = "epsg:4326" +#' +#' # Lastly we can use elev() +#' elev_data <- elev(location = location) +#' #' @importFrom elevatr get_elev_raster #' @importFrom methods as #' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- -#' @importFrom terra rast extract xyFromCell mosaic writeRaster rast +#' @importFrom terra extract mosaic rast rasterize vect writeRaster xyFromCell #' @export elev <- function(output_dir, location, e_source = "mapzen", ...) { diff --git a/data/srtm_tiles.rda b/data/srtm_tiles.rda new file mode 100644 index 0000000000000000000000000000000000000000..b08b812801c34be9b596dc2cc4eff36402168cff GIT binary patch literal 17088 zcmdseWmH>1*Df_$DDDnL8ytdbDOB*{?hrJ%Yg^ol6C}6=D=tBbTX1)Gcc)+azTdj* z{=5J0vrcAaot%@iXP-TL_I_saQQJb0OG1lLMXTiXbH?W-Qh)!SSWyvwcKID;1O*9G z@4GC*_y1ZS&|f{1kbd_@X9e@kILfor%U5_PYAA#s?ySB)57Y=Fp!!aLVu6l>4L?|1 zP;>1@I1+US)y&r)w6&awKL3%O%OH_m51`4=68q zk*9dbj9<`*e&8WPK|vn>H1y&FCbEJ09eKl}%vbrZ7SdbUrsE@z-zEk>2k%VGsq|A# z%<*2dXHd zTke71JSy$+TtM@!z=}$lqkEH>`YjaJ6>Y-dMhX(ucJgp&+Ar*XBRJtr{Kdc zGrUAJ#-YKX?#t&0?(1w`0eie8zQbv|yt1L7A^^A{JHFv6#oMjAFt1?vvJ;aVrZ9e& z>UPX~(YPtqjf=nY`+ZvT_~k-=z&@99eDi0fUq091O}BTlzKTEliJj;ZUR!;GQA(*m zTS@wXC(gUL&u~5&O0ycu+TgZsM=as|F;ZOq62vv*ANkGkJ+>PW-@~5Vv%eMjf`rkm zu)z)Vc3y{$a!N%~^$1g^o&u3#y3AO6*1^T1tNCR1ZTc_o3!`5!nmGoUWOGMGMrk4z z)AJ4cK=S3EEh!+ycyhCMD}6q`HoF62nP*^msC%1P^t0RGJsGURi;LIcDZD~-*15oR z%hTPEIVaIVzLXrN>6E3;MR6YO4wh?cIqAWJ!QYfGx zcl_`}H_6ZUK1(s!8X%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x+UMx+Xssiz2YcwQ-^VfOix;HMVF)G0= zpxdT8{&k|`4B z^eq)_WQL%X(yq=8DY98o2Rn65#rIPgpQGKWlE3V{yOj1ubKD$|=UK=A$UJ7YIzvaP zJ%d@IS*TW$JgK2NhgbKW8ow20M0a__cB1&nBR4|%i%)+owsha$^zrn4daTmMLS)Q*7 zg226elc(?Suz%)0UI=8&cf9w?4Le5{4?rr;h3n|0E%OtD;M@Ftm)YJ1u2U&H+q#;J zpeQH?hZp|EKwww*a5~E=x{s!4SXjAojvqONodC5+d&1)2ewE|sE%^G({#aQ{Ar3(#b(VB#>b=fHTI1Jjy|~@p;_ta5ugKRj;inog>;Ov z+U9EY+SVMeO=EI&K{}Ps=KEgeC=;I8n?<`ieJyId zoD1c90xD1CiHV6T<3k6!q0W}8FZzs|IYdCb%RrA!Y$Jdlsm$)~?zp@dDscktg#|KF zKKkSZi=I+(y(d3Lle`+7uZWx;j9#H%1UL4?yG>Gok(V5^*Kvxcl=6&Kq*x#jrO4=7 ztev1>z-N>WgQh#C!$S%&q zyR2Z3jUp&23rU%qWuWyoW3!j5OAv_v;-vw`TVamAQ@Y?zYGrnI5wXbjTgi6*7`g?M z8rW|S?GMC1_=KOy>=+iqB~z5JABZ3CSZ?t?EmS7S-;aw5ooa{4f#$Yr*9yui$)Ld( XZ;p4J$MiS6fi~^^SM?V^@KOE;cUPuS literal 0 HcmV?d00001 diff --git a/man-roxygen/output_e_source_param.R b/man-roxygen/output_e_source_param.R index 8b33db5..66d5307 100644 --- a/man-roxygen/output_e_source_param.R +++ b/man-roxygen/output_e_source_param.R @@ -1,2 +1,2 @@ -#' @param e_source Character (e.g., `mapzen` or `WorldClim`). Indicating the +#' @param e_source Character (e.g., `mapzen` or `geodata`). Indicating the #' elevation data source. diff --git a/man/ce_download.Rd b/man/ce_download.Rd index ec56728..a035c63 100644 --- a/man/ce_download.Rd +++ b/man/ce_download.Rd @@ -20,7 +20,7 @@ the data will be stored.} \item{c_source}{Character (e.g., \code{"CHELSA or WorldClim"}). Indicating the climate data source.} -\item{e_source}{Character (e.g., \code{mapzen} or \code{WorldClim}). Indicating the +\item{e_source}{Character (e.g., \code{mapzen} or \code{geodata}). Indicating the elevation data source.} \item{var}{Character. If supplied will download a subset of the climate data. diff --git a/man/elev.Rd b/man/elev.Rd index afffc21..bb29a56 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -14,7 +14,7 @@ the data will be stored.} \link[sf:st]{sf::st_polygon} to make polygons and \link[sf:st_as_sf]{sf::st_as_sf} to make point objects.} -\item{e_source}{Character (e.g., \code{mapzen} or \code{WorldClim}). Indicating the +\item{e_source}{Character (e.g., \code{mapzen} or \code{geodata}). Indicating the elevation data source.} \item{\dots}{Additional arguments to \code{\link[=download.file]{download.file()}}.} @@ -37,11 +37,33 @@ latitudes between -60 and 60 or Mapzen's synthesis digital elevation product. } \examples{ \dontrun{ -# Start by loading Italy's Biom data +# We could do this using Italy's Biome data data("italy_py", package = "climenv") # elevation will be saved in the output_dir (i.e. output directory) elev(output_dir = "...Desktop/elev", location = italy_py) } + +Or a smaller example we can make a polygon covering an island in the ocean. + +location <- sf::st_polygon( + list( + cbind( + long = c(161, 161, 154, 161), + lat = c(-61, -49, -61, -61) + ) + ) +) + +# We need to make sure that the polygon the correct class +location <- sf::st_geometry(location) +class(location) # "sfc_POLYGON" "sfc" + +# Lets make sure to set the coordinate reference system +sf::st_crs(location) = "epsg:4326" + +# Lastly we can use elev() +elev_data <- elev(location = location) + } \references{ { Hijmans, R.J., Barbosa, M., Ghosh, A., & Mandel, A. (2023). @@ -61,7 +83,8 @@ ISPRS International Journal of Geo-Information 8, 108. } \seealso{ A more convenient function for other climate and elevation data -\code{\link[=ce_download]{ce_download()}}. +\code{\link[=ce_download]{ce_download()}}. See \link[sf:st]{sf::st_polygon} to make polygons and \link[sf:st_as_sf]{sf::st_as_sf} +to make point objects. } \author{ James L. Tsakalos diff --git a/man/srtm_tiles.Rd b/man/srtm_tiles.Rd new file mode 100644 index 0000000..6bef659 --- /dev/null +++ b/man/srtm_tiles.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/data_srtm_tiles.R +\docType{data} +\encoding{UTF-8} +\name{srtm_tiles} +\alias{srtm_tiles} +\title{STRM tiles data} +\format{ +{ An object of class \code{SpatialPolygonsDataFrame} with 872 rows +and 1 columns.} +} +\usage{ +srtm_tiles +} +\description{ +SRTM tiles data. +} +\details{ +Contains tiles to assist downloading from 'geodata'. +} +\examples{ +data("srtm_tiles", package = "climenv") +head(srtm_tiles) +} +\keyword{datasets} diff --git a/tests/testthat/expected/mapzen.tif b/tests/testthat/expected/mapzen.tif new file mode 100644 index 0000000000000000000000000000000000000000..97a1701a710fe08ecd933fb7dd2cb0f8832a2f19 GIT binary patch literal 11372 zcma)i4OA1?w*SoJYw}45Aq?RolMgWwD>4eQUk9{%gJWpS8~H z-^|&2pL1sKv(K5cc5ZGQ00RIJ0stTh00T%7DBvGBHGrW%FdD$5KQJYLsej<#Wr9I6 z00ro?KneYC?*)J0xWN0cKX{%5aO8jEdFj95m49GTfQMsY0l(9&0mWu33!nyYa{zzX zLIThLJ|DpD7S_MoeHy@LTA+W8gc=YcdLUqPpkq*=m;#vmyB@>Vz#RZCqX6)BV91;R z-`7$A$jH&C@|UfzGgKJr44DiR&B(1=zXjcD*s}g5$;u*CQSQp3+^m(aEK`-_E?c!s zf^Ii#si_XsDI}TmlTwlr7N(~rr=>1brY&5Mk@&mp|E45cwfui-NDo~9w^;7-|F`W0 z3)2@QB&REt%H*UpW%B>2WMz>?lU@A(+qx!uWmaLXz9@Ia|L8DU`|9swuUNmmymn(v z-Nsk9N-`@qR#`0k$N%C(6N z^!gVEjketVS!i(w=QZb;3&;@5ujeYuh^y)*ZoBb3PaWN5kAQ+v|>{5_z65dhB%A*Higld-SvuhjPHd#6wJF` z+!F*oLzjjy!9A=G*3T9nA-6pAyuqHrxGC{uRi#_F{t1eO>4=F&F=Tk5>N+ldvcx6L zlkW`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x#%mH_(Rki*q{VT!Vp6 z@t!LN-Sbr93Q>nAmA>0?J($o8nE!Gu)3Wjb6E9*1-^^lYNAc~_*|kaHHsxNdHtZpv z(lp6adTx#&6TVJZS!SnAbse7QrbNFG;s8P(OLZCNw&HNV{nB6F$s9NGOAq)rT# zEd6BPSo#>|2|0i=Ie)>@Y}og-A#7<|Ey8Rr;EJRbZZ`O3akJwuD?AxkQy3(s;h@Lfz&L&9+h@(F}(3;l;=lDv@7Z@&{S)saQ6n1dH4stg-F(M7g~CB;&n zyr7u93I_MVNh>#ZJ39Jix>zlEfIUQRWvm42Af@_(i-YUj&@?25Px;$j@V7v+{-o{8SD3Pl*W>eqW^%-%xB2{iA9p=s=WOPZ)TdUu1!%l;rR_ zQ2p@&GkD`yv+rQB$(k*}5|jrWE&RXR;>l0YxjBz~QQ#Y^NKT25K<3KKiUsNDBge=_6G`+t#< F{}bgSY*zpP literal 0 HcmV?d00001 diff --git a/tests/testthat/expected/mapzen_pt.tif b/tests/testthat/expected/mapzen_pt.tif new file mode 100644 index 0000000000000000000000000000000000000000..de2524481becf9134bb80f5b8967235cce8af3e4 GIT binary patch literal 980 zcmebD)MDUZU|*y7Mi#K%KTHe^ zqDbOmP&UXMaj2RbK(-8$8e1fGFqF*<#Ta3_yzE36R*>&IIX=5LUCelK@L#PK*>(m(!xy7 z+|4#~zsi~QPp0SCcxuuzfIbo}VLtI>3 z!-%!q#WmPD$TJ|s(;vmX3Pt%KucxFICl_TFlw{`TDcPlE=A@b#CmNWiT9_D{B*J}T zqmLT03}@?=0xGmF*&l$?;NZtY{0D*c$qw>@i}$5H_C5ep$_P$d>Es!{;6TraOP+x0% zDJMMo!jGf1k{&%lmpDX@@~?N(33Hmra#VdBAxVhMrkGgm!wX8v(WnGlL$Bly$|3<9tPSP4 z6+Vlw@M>>#PmMm!`=Byu*4aw#&OaVEJRbJ4v1wVBh$bxzKUAjm@IXLPcc)q|SJI~v Y73qjYi{_oy-oEUe%J0ShK36gV0CDX0TL1t6 literal 0 HcmV?d00001 diff --git a/tests/testthat/expected/srtm.tif b/tests/testthat/expected/srtm.tif new file mode 100644 index 0000000000000000000000000000000000000000..da501f75c6161f237112a791d481f5d325f3293f GIT binary patch literal 4886 zcmeH|iCa_07Qp8wAtZq0vM&a`gs`KAfNYYOKmtSxLMv`}e|HjMu8-*}d1bSASl zFHk1`!G`e%4xMEzYNNYD2h7M?3;=~P9e_vqJjy4Fu>e8&3CgNs9e@hpgc_bI#(bQK zH_B49lL(E)2Q39C<4~J4Q5sqU5QRFTe~fb`*8g8rs2vCObBGAQEj0KsZ2;cs0HCi6 zfGr6CZy11;dH^KqqwLRNe-e}+7R8IiBBmCCc=N;wsYseAHGx416|e=oPyx?3G&+bK z!3zotq9B=~)Ql8VN24(5&Mu3c-Cb$!bh_J8Hy7_EGhP462bUfECkKl>(eLlO@q+(n zXlK{OG#bs*9UYgx^lv?c3OF2Y_&*(*!wvOa#p4TjA%BV%*_=Kz@A!nwxXsBK;^g!+ z3Nv%FI5pa3X|yx__ZYmF{CPnE2$?_DQV@K6`S0@MHvVlzRsYw-koCJM^fA9R!Av?p zXx^X+iAppD&;tO05f~zzDn_*c|FK*L<;tGq}%`^U3^@0et&_5LM zaLof!0Ccd^T10%I`XOzrfMPMP#FxTvt!3I8?<_K{g`w1XHllUqvJGGnd=RgH;jExA zZR$qH;gZB;B9N?;OQBA&yy!tWen4goMHM^oT!wc_+4I!vvwL-L|B8J|3G*d z4(ZeHj{wc{0qae<<359g8b2{f|7InY*mvk2c|I7qaw>0+mW^V;wLTUvkzYl>2JAg8 zpWL(CkPPG81e>jl9(Q`Kt&Web>KYa2STLglkKZ1BH5FAoy5`)#v#qg>Eqga1(})sl zncQsc$A*o6Rb$N5GGv`4Ay{K4J;jz$1ej*FoZexiQWK#mmQDU}MbjJp%#wIf)wodG zhu=ZwRPW}M;OejZyBh~TcA3=GFYT>ec_Eg);+^7h?xfJA10oq7#9fZyn{yupP{ao+)%ht+AivJj$lRf_IG z!o$70<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diff --git a/tests/testthat/expected/srtm_pt.tif b/tests/testthat/expected/srtm_pt.tif new file mode 100644 index 0000000000000000000000000000000000000000..9ebbc0c511e55102e26e2ae42a2190178f92a45c GIT binary patch literal 2242 zcmebD)MDUZU|-pD0L7W1Y*rwf4ax@T5oBaxfQT_Lh$4xL zLD`}}HR4b;pMY!`BsI23>|iLH8K{P@nTG*HS1~a#G_~+BumRbVfb8|{%nS-Z_8}m9 zLpu)xkYZp0D%{x41onv#klnC^i6H^#FexBz1hQFxYVs2EfFuLM1fZA<50F=Dk&5v<`(1th%2ncKQ z^uw^(&`i(7z}(2l%+$kK$T|qI{6IQ&NkQi!uvJ zGV}A4?23y@a^sE7;th>pzOd0p4NnGt=@(lX{Z`w z@y7^E4Zvguq=69(OxBDH&jc7bHnsz08Q8%5K4ngh4ecO#ZZOTj(2-j*O?F8U$UKK- zArX$@?!gKcCN&HV3=BNXf4Df=nhrcPs0dM#%~3hq0zNr39dK^eSXlUzv*C=asmYlZzz&Obb_@eky4O|A$zE#4=qyjYW!UMcGaq zepVW3n-(3u?%FdmtH09@=We~@D8jHbRy5DO<6`TcjF{ru=rwKDD>uQV#22-2xm^7v%Zta5Tv z%v=@EPaz96PX(=+Eux@6LVUQZO*)ZkR2i};R(FQCTF}lV`_j#3ok=&Yyz;2lc7eY} z@Gg~q?QV-MWSUfkD$Vs>5v&!mYpLDxuvJ&GO{=aZ?Ty_Kt`oXjweEP@rW?6t)uD^- z=I)5r3){VP-}ACvck<1vuRi))dm!E*e2?mX_O?S03N32Flx2HQBpXHSS!S<3?bMTE z%bIJ+wsS9}n?&wat9M^^=|!nkZP?=2wKuZOqV_J^pT6zZn{w;gYmaO9KFGI--lz7z z{n(=ql{R(Z%5%@YD7K2(x7>dDwO3!NZR@Tl@4fq>+$MIvdj0WdpMKQZ)rT*>`}Rk* cUEKcV`=5XN^(SkBz-ZWvhRujfH&r1l0HEznv;Y7A literal 0 HcmV?d00001 diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 4c1a834..e67c059 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -28,6 +28,7 @@ test_that("elev() fails gracefully", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) + # When location is not supplied # This is testing R's functionality, rather than our packages, so does # not need to be included in this package's test suite; # we do not handle the case where no parameters are specified. @@ -37,6 +38,7 @@ test_that("elev() fails gracefully", { "Error in elev() : argument location is missing, with no default" )) + # Invalid polygon flip_lat_long <- sf::st_polygon(list(cbind( lat = c(-61, -49, -61, -61), lng = c(161, 161, 154, 161) @@ -92,3 +94,133 @@ test_that("elev()", { skip_if_not_installed("vdiffr") vdiffr::expect_doppelganger("geo-elev", function() terra::plot(geo_elev)) }) + +test_that("elev() downloads data", { + + skip_if_offline() # Requires connectivity + skip_on_cran() # download is slow + + # CRAN policy: Packages should not write [anywhere] apart from the + # R session’s temporary directory [...] and such usage should be cleaned up + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + + # Make a polygon + location <- sf::st_polygon( + list(cbind(long = c(161, 161, 154, 161), + lat = c(-61, -49, -61, -61))) + ) + location <- sf::st_geometry(location) + sf::st_crs(location) <- "epsg:4326" + + # polygon and mapzen tiles #### + elev( + output_dir = tmp_dir, location = location, e_source = "mapzen" + ) + mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_equal(file.exists(mapzen_tile), TRUE) + + # Check data matches expectation + skip_if(!file.exists(mapzen_tile[1])) + elev_mapzen <- terra::rast(mapzen_tile[1]) + thumb_1 <- terra::aggregate(elev_mapzen, fact = 64) + expected <- terra::rast(test_path("expected", "mapzen_py.tif")) + expect_true(all.equal(rast(thumb_1), terra::rast(expected))) + + # Run this code manually to update the "Expected" value + if (FALSE) { + terra::writeRaster( + thumb_1, overwrite = TRUE, + test_path("expected", "mapzen_py.tif") + ) + } + + unlink(tmp_dir) + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + + # polygon and geodata #### + elev( + output_dir = tmp_dir, location = location, e_source = "geodata" + ) + srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_equal(file.exists(srtm_tile), TRUE) + + # Check data matches expectation + skip_if(!file.exists(srtm_tile[1])) + elev_srtm <- terra::rast(srtm_tile[1]) + thumb_2 <- terra::aggregate(elev_srtm, fact = 64) + expected <- terra::rast(test_path("expected", "srtm_py.tif")) + expect_true(all.equal(rast(thumb_2), terra::rast(expected))) + + # Run this code manually to update the "Expected" value + if (FALSE) { + terra::writeRaster( + thumb_2, overwrite = TRUE, + test_path("expected", "srtm_py.tif") + ) + } + + # Now for points + location <- terra::centroids(terra::vect(location)) + + unlink(tmp_dir) + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + + # I expect error because the package does not accept spatvectors + expect_error(elev(output_dir = tmp_dir, + location = location)) + + # sf class is okay. + location <- sf::st_as_sf(location) + + # point and mapzen tiles #### + elev( + output_dir = tmp_dir, location = location, e_source = "mapzen" + ) + mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_equal(file.exists(mapzen_tile), TRUE) + + # Check data matches expectation + skip_if(!file.exists(mapzen_tile[1])) + elev_mapzen <- terra::rast(mapzen_tile[1]) + thumb_3 <- terra::aggregate(elev_mapzen, fact = 64) + expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) + expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) + + # Run this code manually to update the "Expected" value + if (FALSE) { + terra::writeRaster( + thumb_3, overwrite = TRUE, + test_path("expected", "mapzen_pt.tif") + ) + } + + unlink(tmp_dir) + tmp_dir <- tempdir() + on.exit(unlink(tmp_dir)) + + # polygon and geodata + elev( + output_dir = tmp_dir, location = location, e_source = "geodata" + ) + srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_equal(file.exists(srtm_tile), TRUE) + + # Check data matches expectation + skip_if(!file.exists(srtm_tile[1])) + elev_srtm <- terra::rast(srtm_tile[1]) + thumb_4 <- terra::aggregate(elev_srtm, fact = 64) + expected <- terra::rast(test_path("expected", "srtm_pt.tif")) + expect_true(all.equal(terra::rast(thumb_4), terra::rast(expected))) + + # Run this code manually to update the "Expected" value + if (FALSE) { + terra::writeRaster( + thumb_4, overwrite = TRUE, + test_path("expected", "srtm_pt.tif") + ) + } + +}) From 4c68daa2d1f5c3b36e5ce7cf75fdfec7660f6234 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:14:13 +0100 Subject: [PATCH 30/61] Update NAMESPACE --- NAMESPACE | 1 + 1 file changed, 1 insertion(+) diff --git a/NAMESPACE b/NAMESPACE index c9e525a..6cf4741 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -49,6 +49,7 @@ importFrom(terra,crds) importFrom(terra,extract) importFrom(terra,mosaic) importFrom(terra,rast) +importFrom(terra,rasterize) importFrom(terra,rowFromCell) importFrom(terra,vect) importFrom(terra,writeRaster) From 42b22c07eca73f61f5ee3a87907e370fb99ea50c Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:18:20 +0100 Subject: [PATCH 31/61] Spatial-ize "sfc" objects too --- R/elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/elev.R b/R/elev.R index 245ee18..6f45d15 100644 --- a/R/elev.R +++ b/R/elev.R @@ -158,7 +158,7 @@ elev <- function(output_dir, location, e_source = "mapzen", ...) { stop("e_source must be \"mapzen\" or \"geodata\"") } - if ("sfg" %in% class(location)) { + if (any(c("sfc", "sfg") %in% class(location))) { location <- as(location, "Spatial") } location_sf <- as(location, "sf") From fe2c4b21aa493ad249e6f5022c8828c15de9ec60 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:18:55 +0100 Subject: [PATCH 32/61] load sp quietly --- tests/testthat.R | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/testthat.R b/tests/testthat.R index ea9b06b..5a7db44 100644 --- a/tests/testthat.R +++ b/tests/testthat.R @@ -1,4 +1,5 @@ -library(testthat) -library(climenv) +suppressPackageStartupMessages(library("sp", quietly = TRUE)) # Until Oct 2023 +library("testthat") +library("climenv") test_check("climenv") From f1e2ae0fc07619369c9bad55b83a1e59a95225af Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:19:03 +0100 Subject: [PATCH 33/61] skip_on_cran implicit --- tests/testthat/test-elev.R | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index e67c059..61562f8 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -97,8 +97,7 @@ test_that("elev()", { test_that("elev() downloads data", { - skip_if_offline() # Requires connectivity - skip_on_cran() # download is slow + skip_if_offline() # Requires connectivity. Automatically skips on CRAN. # CRAN policy: Packages should not write [anywhere] apart from the # R session’s temporary directory [...] and such usage should be cleaned up From 0f4927b6d2e8bedb0048cc551ee7b971146e1563 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:28:24 +0100 Subject: [PATCH 34/61] st_as_sf --- R/elev.R | 5 ++++- tests/testthat/test-elev.R | 6 ------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/R/elev.R b/R/elev.R index 6f45d15..06ae3ab 100644 --- a/R/elev.R +++ b/R/elev.R @@ -148,7 +148,7 @@ #' #' @importFrom elevatr get_elev_raster #' @importFrom methods as -#' @importFrom sf as_Spatial st_geometry st_bbox st_is_longlat st_crs<- +#' @importFrom sf as_Spatial st_as_sf st_bbox st_geometry st_is_longlat st_crs<- #' @importFrom terra extract mosaic rast rasterize vect writeRaster xyFromCell #' @export elev <- function(output_dir, location, e_source = "mapzen", ...) { @@ -158,6 +158,9 @@ elev <- function(output_dir, location, e_source = "mapzen", ...) { stop("e_source must be \"mapzen\" or \"geodata\"") } + if (is.function(location)) { + location <- st_as_sf(location) + } if (any(c("sfc", "sfg") %in% class(location))) { location <- as(location, "Spatial") } diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 61562f8..f8f1cb5 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -167,12 +167,6 @@ test_that("elev() downloads data", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # I expect error because the package does not accept spatvectors - expect_error(elev(output_dir = tmp_dir, - location = location)) - - # sf class is okay. - location <- sf::st_as_sf(location) # point and mapzen tiles #### elev( From c770bbc2ae57e2356bc3fccc0ac2f2599d06daba Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:34:37 +0100 Subject: [PATCH 35/61] Separate tests for each assertion Clarifies workflow and allows granular skipping --- tests/testthat/test-elev.R | 91 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f8f1cb5..8f65584 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -1,3 +1,12 @@ +polygon <- sf::st_polygon( + list(cbind(long = c(161, 161, 154, 161), + lat = c(-61, -49, -61, -61))) + ) +polygon <- sf::st_geometry(polygon) +sf::st_crs(polygon) <- "epsg:4326" +points <- terra::centroids(terra::vect(polygon)) + + scrub_progress_bars <- function(x) { progress_bars <- grep("^[\\|\\-=\\s]*$", x, perl = TRUE) if (length(progress_bars)) { @@ -95,8 +104,7 @@ test_that("elev()", { vdiffr::expect_doppelganger("geo-elev", function() terra::plot(geo_elev)) }) -test_that("elev() downloads data", { - +test_that("elev() downloads polygon from Mapzen", { skip_if_offline() # Requires connectivity. Automatically skips on CRAN. # CRAN policy: Packages should not write [anywhere] apart from the @@ -104,20 +112,12 @@ test_that("elev() downloads data", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # Make a polygon - location <- sf::st_polygon( - list(cbind(long = c(161, 161, 154, 161), - lat = c(-61, -49, -61, -61))) - ) - location <- sf::st_geometry(location) - sf::st_crs(location) <- "epsg:4326" - # polygon and mapzen tiles #### elev( - output_dir = tmp_dir, location = location, e_source = "mapzen" + output_dir = tmp_dir, location = polygon, e_source = "mapzen" ) mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") - expect_equal(file.exists(mapzen_tile), TRUE) + expect_true(file.exists(mapzen_tile)) # Check data matches expectation skip_if(!file.exists(mapzen_tile[1])) @@ -133,73 +133,75 @@ test_that("elev() downloads data", { test_path("expected", "mapzen_py.tif") ) } - - unlink(tmp_dir) +}) +test_that("elev() downloads points from Mapzen", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # polygon and geodata #### elev( - output_dir = tmp_dir, location = location, e_source = "geodata" + output_dir = tmp_dir, location = points, e_source = "mapzen" ) - srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") - expect_equal(file.exists(srtm_tile), TRUE) + mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_true(file.exists(mapzen_tile)) # Check data matches expectation - skip_if(!file.exists(srtm_tile[1])) - elev_srtm <- terra::rast(srtm_tile[1]) - thumb_2 <- terra::aggregate(elev_srtm, fact = 64) - expected <- terra::rast(test_path("expected", "srtm_py.tif")) - expect_true(all.equal(rast(thumb_2), terra::rast(expected))) + skip_if(!file.exists(mapzen_tile[1])) + elev_mapzen <- terra::rast(mapzen_tile[1]) + thumb_3 <- terra::aggregate(elev_mapzen, fact = 64) + expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) + expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) # Run this code manually to update the "Expected" value if (FALSE) { terra::writeRaster( - thumb_2, overwrite = TRUE, - test_path("expected", "srtm_py.tif") + thumb_3, overwrite = TRUE, + test_path("expected", "mapzen_pt.tif") ) } +}) - # Now for points - location <- terra::centroids(terra::vect(location)) - unlink(tmp_dir) +test_that("elev() downloads polygon from GeoData", { + skip_if_server_offline("srtm.csi.cgiar.org") + tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - - # point and mapzen tiles #### + # polygon and geodata #### elev( - output_dir = tmp_dir, location = location, e_source = "mapzen" + output_dir = tmp_dir, location = polygon, e_source = "geodata", quiet = TRUE ) - mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") - expect_equal(file.exists(mapzen_tile), TRUE) + srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") + expect_true(file.exists(srtm_tile)) # Check data matches expectation - skip_if(!file.exists(mapzen_tile[1])) - elev_mapzen <- terra::rast(mapzen_tile[1]) - thumb_3 <- terra::aggregate(elev_mapzen, fact = 64) - expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) - expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) + skip_if(!file.exists(srtm_tile[1])) + elev_srtm <- terra::rast(srtm_tile[1]) + thumb_2 <- terra::aggregate(elev_srtm, fact = 64) + expected <- terra::rast(test_path("expected", "srtm_py.tif")) + expect_true(all.equal(rast(thumb_2), terra::rast(expected))) # Run this code manually to update the "Expected" value if (FALSE) { terra::writeRaster( - thumb_3, overwrite = TRUE, - test_path("expected", "mapzen_pt.tif") + thumb_2, overwrite = TRUE, + test_path("expected", "srtm_py.tif") ) } +}) + + +test_that("elev() downloads points from GeoData", { + skip_if_server_offline("srtm.csi.cgiar.org") - unlink(tmp_dir) tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # polygon and geodata elev( - output_dir = tmp_dir, location = location, e_source = "geodata" + output_dir = tmp_dir, location = points, e_source = "geodata", quiet = TRUE ) srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") - expect_equal(file.exists(srtm_tile), TRUE) + expect_true(file.exists(srtm_tile)) # Check data matches expectation skip_if(!file.exists(srtm_tile[1])) @@ -215,5 +217,4 @@ test_that("elev() downloads data", { test_path("expected", "srtm_pt.tif") ) } - }) From 78ae56e8a862b02e6e6b6e36c8216aaa93846ee1 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 08:35:36 +0100 Subject: [PATCH 36/61] Support SpatVectors --- R/elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/elev.R b/R/elev.R index 06ae3ab..07d13ee 100644 --- a/R/elev.R +++ b/R/elev.R @@ -161,7 +161,7 @@ elev <- function(output_dir, location, e_source = "mapzen", ...) { if (is.function(location)) { location <- st_as_sf(location) } - if (any(c("sfc", "sfg") %in% class(location))) { + if (any(c("sfc", "sfg", "SpatVector") %in% class(location))) { location <- as(location, "Spatial") } location_sf <- as(location, "sf") From 2d8fb9b1293119f4f2cb5b42f99678825c790e9d Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Wed, 12 Jul 2023 12:02:32 +0100 Subject: [PATCH 37/61] Squashed commit of the following: commit 122d3d7ef471efecd2625983423c8de049e172e0 Author: Martin R. Smith <1695515+ms609@users.noreply.github.com> Date: Wed Jul 12 12:01:52 2023 +0100 uncomment commit 7802e82484e26eee6ee1f559fc97d312ac02df39 Author: Martin R. Smith <1695515+ms609@users.noreply.github.com> Date: Tue Jul 11 22:38:36 2023 +0100 sp commit fbffb8577df264ed20f7336a5230647dbfae094d Author: Martin R. Smith <1695515+ms609@users.noreply.github.com> Date: Tue Jul 11 22:35:51 2023 +0100 Explore error commit 3cc191dc4aa2938e5a658bb946be214187533ac3 Author: Martin R. Smith <1695515+ms609@users.noreply.github.com> Date: Tue Jul 11 22:04:04 2023 +0100 define file_path outside switch commit f0c143ec489a9a294cc5fbe450ac5a659761a175 Author: Martin R. Smith <1695515+ms609@users.noreply.github.com> Date: Tue Jul 11 21:58:45 2023 +0100 Avoid rgdal --- DESCRIPTION | 4 +++- R/elev.R | 38 ++++++++++++++++++-------------------- man/elev.Rd | 7 +++++-- tests/testthat/test-elev.R | 9 +++++---- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9d21872..732396c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -38,7 +38,7 @@ Imports: climaemet, dismo, dplyr, - elevatr, + elevatr (>= 1.0), exactextractr, geodata, glue, @@ -58,6 +58,8 @@ Suggests: rmarkdown, testthat (>= 3.0.0), vdiffr +Remotes: + jhollist/elevatr Config/Needs/check: rcmdcheck Config/Needs/coverage: covr Config/Needs/website: pkgdown diff --git a/R/elev.R b/R/elev.R index 07d13ee..41cbd0d 100644 --- a/R/elev.R +++ b/R/elev.R @@ -85,6 +85,8 @@ #' @template output_dir_param #' @template output_location_param #' @template output_e_source_param +#' @param verbose Logical specifying whether to display verbose output when +#' downloading from Mapzen. #' @param \dots Additional arguments to [`download.file()`]. #' #' @return @@ -107,7 +109,7 @@ #' https://CRAN.R-project.org/package=geodata #' #' Hollister, J. (2022). elevatr: Access Elevation Data from Various -#' APIs. R package version 0.4.2. \doi{10.5281/zenodo.5809645} +#' APIs. R package version 1.0.0. \doi{10.5281/zenodo.5809645} #' https://CRAN.R-project.org/package=elevatr #' #' Mouratidis, A., & Ampatzidis, D. (2019). European Digital Elevation Model @@ -151,7 +153,8 @@ #' @importFrom sf as_Spatial st_as_sf st_bbox st_geometry st_is_longlat st_crs<- #' @importFrom terra extract mosaic rast rasterize vect writeRaster xyFromCell #' @export -elev <- function(output_dir, location, e_source = "mapzen", ...) { +elev <- function(output_dir, location, e_source = "mapzen", + verbose = FALSE, ...) { e_source_id <- pmatch(tolower(e_source[1]), c("mapzen", "geodata")) if (is.na(e_source_id)) { @@ -189,24 +192,19 @@ elev <- function(output_dir, location, e_source = "mapzen", ...) { recursive = TRUE, showWarnings = FALSE) } + file_path <- paste0(output_dir, "/elev/srtm.tif") # Saves elevation from geodata or mapzen sources - switch(e_source_id, - { # mapzen - srtm_mosaic <- terra::rast( - elevatr::get_elev_raster( - location_sf, z = 7, override_size_check = TRUE, - progress = FALSE - ) - ) - file_path <- paste0(output_dir, "/elev/srtm.tif") - terra::writeRaster(srtm_mosaic, filename = file_path, - overwrite = TRUE) - }, - { # geodata - srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) - file_path <- paste0(output_dir, "/elev/srtm.tif") - terra::writeRaster(srtm_mosaic, filename = file_path, - overwrite = TRUE) - } + switch(e_source_id, { # mapzen + elev_raster <- elevatr::get_elev_raster( + location_sf, z = 7, override_size_check = TRUE, + progress = verbose, verbose = verbose + ) + srtm_mosaic <- terra::rast(elev_raster) + terra::writeRaster(srtm_mosaic, filename = file_path, + overwrite = TRUE) + }, { # geodata + srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) + terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) + } ) } diff --git a/man/elev.Rd b/man/elev.Rd index bb29a56..bf4a91c 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -4,7 +4,7 @@ \alias{elev} \title{Download elevation data} \usage{ -elev(output_dir, location, e_source = "mapzen", ...) +elev(output_dir, location, e_source = "mapzen", verbose = FALSE, ...) } \arguments{ \item{output_dir}{Character (e.g., \code{"../Desktop/chelsa"}). Pathway to where @@ -17,6 +17,9 @@ objects.} \item{e_source}{Character (e.g., \code{mapzen} or \code{geodata}). Indicating the elevation data source.} +\item{verbose}{Logical specifying whether to display verbose output when +downloading from Mapzen.} + \item{\dots}{Additional arguments to \code{\link[=download.file]{download.file()}}.} } \value{ @@ -71,7 +74,7 @@ geodata: Download Geographic Data. R package version 0.5-8. https://CRAN.R-project.org/package=geodata Hollister, J. (2022). elevatr: Access Elevation Data from Various -APIs. R package version 0.4.2. \doi{10.5281/zenodo.5809645} +APIs. R package version 1.0.0. \doi{10.5281/zenodo.5809645} https://CRAN.R-project.org/package=elevatr Mouratidis, A., & Ampatzidis, D. (2019). European Digital Elevation Model diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 8f65584..924753f 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -95,10 +95,11 @@ test_that("elev()", { "Could not download srtm_6._2."), "Coordinate reference system not specified") - #cran = TRUE, error = FALSE, scrub_progress_bars) - # Expect the warnings: - # "Coordinate reference system not specified", - # "Could not download srtm_6._2." + # TODO JS to investigate: + # elev.R:172 terra::writeRaster(srtm_mosaic, filename = file_path, [...] + # throws + # Error: [writeRaster] there are no cell values + expect_snapshot(mz_elev <- elev(tmp_dir, island), cran = TRUE) skip_if_not_installed("vdiffr") vdiffr::expect_doppelganger("geo-elev", function() terra::plot(geo_elev)) From e4d7d559fd2b26af8de71934bb1d0e2a752bd272 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Thu, 13 Jul 2023 10:58:24 +0100 Subject: [PATCH 38/61] Comment-out comment (#) --- R/elev.R | 7 +++---- man/elev.Rd | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/R/elev.R b/R/elev.R index 41cbd0d..bd2526e 100644 --- a/R/elev.R +++ b/R/elev.R @@ -127,8 +127,7 @@ #' elev(output_dir = "...Desktop/elev", location = italy_py) #' } #' -#' Or a smaller example we can make a polygon covering an island in the ocean. -#' +#' # As a smaller example, we can make a polygon covering an ocean island. #' location <- sf::st_polygon( #' list( #' cbind( @@ -142,10 +141,10 @@ #' location <- sf::st_geometry(location) #' class(location) # "sfc_POLYGON" "sfc" #' -#' # Lets make sure to set the coordinate reference system +#' # Set the coordinate reference system #' sf::st_crs(location) = "epsg:4326" #' -#' # Lastly we can use elev() +#' # We are now ready to call elev() #' elev_data <- elev(location = location) #' #' @importFrom elevatr get_elev_raster diff --git a/man/elev.Rd b/man/elev.Rd index bf4a91c..d0dfc90 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -46,8 +46,7 @@ data("italy_py", package = "climenv") elev(output_dir = "...Desktop/elev", location = italy_py) } -Or a smaller example we can make a polygon covering an island in the ocean. - +# As a smaller example, we can make a polygon covering an ocean island. location <- sf::st_polygon( list( cbind( @@ -61,10 +60,10 @@ location <- sf::st_polygon( location <- sf::st_geometry(location) class(location) # "sfc_POLYGON" "sfc" -# Lets make sure to set the coordinate reference system +# Set the coordinate reference system sf::st_crs(location) = "epsg:4326" -# Lastly we can use elev() +# We are now ready to call elev() elev_data <- elev(location = location) } From b7a020729dd054c9f21fdab3884450ed01fe45ce Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:53:02 +0100 Subject: [PATCH 39/61] Don't call elev We don't want to write files to user's machine --- R/elev.R | 2 +- man/elev.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/elev.R b/R/elev.R index bd2526e..8fea808 100644 --- a/R/elev.R +++ b/R/elev.R @@ -145,7 +145,7 @@ #' sf::st_crs(location) = "epsg:4326" #' #' # We are now ready to call elev() -#' elev_data <- elev(location = location) +#' # elev(location = location, output_dir = ) #' #' @importFrom elevatr get_elev_raster #' @importFrom methods as diff --git a/man/elev.Rd b/man/elev.Rd index d0dfc90..c15eb1f 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -64,7 +64,7 @@ class(location) # "sfc_POLYGON" "sfc" sf::st_crs(location) = "epsg:4326" # We are now ready to call elev() -elev_data <- elev(location = location) +# elev(location = location, output_dir = ) } \references{ From 67015f381a7cd52c46fe00b0fac99d4c3fa4d37d Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Fri, 14 Jul 2023 13:35:56 +0100 Subject: [PATCH 40/61] `inherits` preferable to `class` --- R/elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/R/elev.R b/R/elev.R index 8fea808..6280dc9 100644 --- a/R/elev.R +++ b/R/elev.R @@ -163,7 +163,7 @@ elev <- function(output_dir, location, e_source = "mapzen", if (is.function(location)) { location <- st_as_sf(location) } - if (any(c("sfc", "sfg", "SpatVector") %in% class(location))) { + if (inherits(location, c("sfc", "sfg", "SpatVector"))) { location <- as(location, "Spatial") } location_sf <- as(location, "sf") From d51bb9d20c82796bcae76ca61e0164c4740679ce Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 17:49:29 +0200 Subject: [PATCH 41/61] corrected srtm code to mask tiles that were in the sea to ensure that the selection of srtm_id was correct. added the `touches = TRUE` arguement to ensure that the intersection also includes tiles where verticies have not been sampled. usage of `as(elev_raster, "SpatTaster")` instead of `terra::rast(elev_raster)`, I'm not sure why but the existing code threw an error. --- R/elev.R | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/R/elev.R b/R/elev.R index 6280dc9..2c0118a 100644 --- a/R/elev.R +++ b/R/elev.R @@ -1,24 +1,20 @@ #' @importFrom terra colFromCell crs<- rowFromCell .elev_geodata <- function(location, output_dir, ...) { + # create SRTM tiles y_max <- 60 y_min <- -60 - # create SRTM tiles - rs <- terra::rast(res = 5, ymin = y_min, ymax = y_max) - rs <- terra::rasterize(terra::vect(climenv::srtm_tiles), rs, "FID") - - # we need to set the crs of the SRTM tiles - terra::crs(rs) <- "epsg:4326" - - # the location crs needs to match the tiles - location <- terra::project(terra::vect(location), rs) + rs <- terra::rast(res = 5, ymin = y_min, ymax = y_max, + vals = 1:1728, crs = "+proj=longlat +datum=WGS84") + # mask out the tiles with no data + rs <- terra::mask(rs, terra::vect(climenv::srtm_tiles), touches = TRUE) - # Intersect location and tiles + # intersect location and tiles tiles <- unique( - terra::extract(rs, location, touches = TRUE)$FID + terra::extract(rs, location, touches = TRUE)$lyr.1 ) - cols <- formatC(colFromCell(rs, tiles), width = 2, flag = 0) - rows <- formatC(rowFromCell(rs, tiles), width = 2, flag = 0) + cols <- formatC(terra::colFromCell(rs, tiles), width = 2, flag = 0) + rows <- formatC(terra::rowFromCell(rs, tiles), width = 2, flag = 0) na <- cols == "NA" | rows == "NA" srtm_id <- paste0("srtm_", cols[!na], "_", rows[!na]) @@ -52,8 +48,8 @@ if (error == 0) { tryCatch(utils::unzip(temp_file, paste0(id, ".tif"), exdir = output_dir), error = function(e) warning("Failed to unzip: ", id)) - rs <- rast(tif) - crs(rs) <- "+proj=longlat +datum=WGS84" + rs <- terra::rast(tif) + terra::crs(rs) <- "+proj=longlat +datum=WGS84" rs } else { NULL @@ -180,9 +176,8 @@ elev <- function(output_dir, location, e_source = "mapzen", } if (!isTRUE(sf::st_is_longlat(location_sf))) { - warning("Coordinate reference system not specified; assuming EPSG:4326") - # TODO JS to check: Should we prefer WGS84 to match output? - st_crs(location_sf) <- "EPSG:4326" + warning("Coordinate reference system not specified; assuming WGS84") + sf::st_crs(location_sf) <- "+proj=longlat +datum=WGS84" } # Create elev folder @@ -198,7 +193,7 @@ elev <- function(output_dir, location, e_source = "mapzen", location_sf, z = 7, override_size_check = TRUE, progress = verbose, verbose = verbose ) - srtm_mosaic <- terra::rast(elev_raster) + srtm_mosaic <- as(elev_raster, "SpatRaster") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) }, { # geodata From 6887fc3ff08820847ed9d7c53f712150e926978a Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 17:52:34 +0200 Subject: [PATCH 42/61] creating smaller test file for mapzen and srtm data to speed up the process. Increased the timeout to 2 seconds to reduce the incorrect decision to abort tests based on slow server response time. Updated the warnings for the island example using srtm data. --- tests/testthat/test-elev.R | 127 +++++++++++++++++++------------------ 1 file changed, 64 insertions(+), 63 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 924753f..6a2e9c2 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -1,11 +1,17 @@ -polygon <- sf::st_polygon( +polygon_py <- sf::st_polygon( list(cbind(long = c(161, 161, 154, 161), lat = c(-61, -49, -61, -61))) ) -polygon <- sf::st_geometry(polygon) -sf::st_crs(polygon) <- "epsg:4326" -points <- terra::centroids(terra::vect(polygon)) +polygon_py <- sf::st_geometry(polygon_py) +sf::st_crs(polygon_py) <- "epsg:4326" +points <- terra::centroids(terra::vect(polygon_py)) +polygon_py_sm <- sf::st_polygon( + list(cbind(long = c(156, 156, 154, 156), + lat = c(-61, -60, -61, -61))) +) +polygon_py_sm <- sf::st_geometry(polygon_py_sm) +sf::st_crs(polygon_py_sm) <- "epsg:4326" scrub_progress_bars <- function(x) { progress_bars <- grep("^[\\|\\-=\\s]*$", x, perl = TRUE) @@ -20,7 +26,7 @@ skip_if_server_offline <- function(server) { # Preferred to testthat::skip_if_offline as this runs on CRAN # Thus we can expect notice of any breaking changes to imported packages tryCatch( - curlGetHeaders(server, timeout = 1), + curlGetHeaders(server, timeout = 2), error = function(e) { if (length(grep("Connection timed out", e$message, fixed = TRUE))) { testthat::skip(paste("Could not connect to", server)) @@ -31,21 +37,12 @@ skip_if_server_offline <- function(server) { test_that("elev() fails gracefully", { - expect_error(elev(out = "", location = "", e_source = ""), - "e_source must be ") - + skip_if_server_offline("srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # When location is not supplied - # This is testing R's functionality, rather than our packages, so does - # not need to be included in this package's test suite; - # we do not handle the case where no parameters are specified. - expect_error( - expect_warning( - elev(), - "Error in elev() : argument location is missing, with no default" - )) + expect_error(elev(out = "", location = "", e_source = ""), + "e_source must be ") # Invalid polygon flip_lat_long <- sf::st_polygon(list(cbind( @@ -57,7 +54,6 @@ test_that("elev() fails gracefully", { "bounding box falls outside supported latitudes" ) - skip_if_server_offline("srtm.csi.cgiar.org") # No data available in the oceans sea <- sf::st_as_sf( data.frame(lat = c(-59, -59, -58, -59), @@ -67,55 +63,48 @@ test_that("elev() fails gracefully", { }) -test_that("elev()", { - skip_if_server_offline("srtm.csi.cgiar.org") +test_that("elev() downloads tiles not containing a vertex srtm", { + skip_if_server_offline("srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # Two squares, 68_24 and 68_23, cover - # Latitude south: 50-60 - # Longitude east: 155-160 - # We should be able to download these squares even if our target area - # overlaps non-existent neighbouring squares + # Island example. Covers two srtm tiles (68_24 and 68_23), but the polygon + # does not cover one tile not containing a vertex. island <- sf::st_polygon( list(cbind(lng = c(161, 161, 154, 161), lat = c(-61, -49, -61, -61)))) - # This polygon covers a tile that does not contain a vertex. - # This tile should be downloaded too + # downloading the data for srtm expect_warning( - expect_warning( - expect_warning( - expect_warning( - expect_warning( geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), - "Could not download srtm_6._2."), - "Could not download srtm_6._2."), - "Could not download srtm_6._2."), - "Could not download srtm_6._2."), "Coordinate reference system not specified") - # TODO JS to investigate: - # elev.R:172 terra::writeRaster(srtm_mosaic, filename = file_path, [...] - # throws - # Error: [writeRaster] there are no cell values - expect_snapshot(mz_elev <- elev(tmp_dir, island), cran = TRUE) + thumb_0 <- terra::aggregate(geo_elev, fact = 20) + + # Run this code manually to update the "Expected" value + if (FALSE) { + terra::writeRaster( + thumb_0, overwrite = TRUE, + test_path("expected", "island_srtm_py.tif") + ) + } + + expected <- terra::rast(test_path("expected", "island_srtm_py.tif")) + expect_true(all.equal(terra::rast(thumb_0), terra::rast(expected))) - skip_if_not_installed("vdiffr") - vdiffr::expect_doppelganger("geo-elev", function() terra::plot(geo_elev)) }) test_that("elev() downloads polygon from Mapzen", { - skip_if_offline() # Requires connectivity. Automatically skips on CRAN. + skip_if_offline() # Requires connectivity. Automatically skips on CRAN. # CRAN policy: Packages should not write [anywhere] apart from the # R session’s temporary directory [...] and such usage should be cleaned up tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # polygon and mapzen tiles #### + # download mapzen using a polygon ### elev( - output_dir = tmp_dir, location = polygon, e_source = "mapzen" + output_dir = tmp_dir, location = polygon_py_sm, e_source = "mapzen" ) mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(mapzen_tile)) @@ -124,8 +113,6 @@ test_that("elev() downloads polygon from Mapzen", { skip_if(!file.exists(mapzen_tile[1])) elev_mapzen <- terra::rast(mapzen_tile[1]) thumb_1 <- terra::aggregate(elev_mapzen, fact = 64) - expected <- terra::rast(test_path("expected", "mapzen_py.tif")) - expect_true(all.equal(rast(thumb_1), terra::rast(expected))) # Run this code manually to update the "Expected" value if (FALSE) { @@ -134,11 +121,19 @@ test_that("elev() downloads polygon from Mapzen", { test_path("expected", "mapzen_py.tif") ) } + + expected <- terra::rast(test_path("expected", "mapzen_py.tif")) + expect_true(all.equal(terra::rast(thumb_1), terra::rast(expected))) + }) + test_that("elev() downloads points from Mapzen", { + + skip_if_offline() # Requires connectivity. Automatically skips on CRAN. tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) + # download mapzen using points elev( output_dir = tmp_dir, location = points, e_source = "mapzen" ) @@ -148,29 +143,31 @@ test_that("elev() downloads points from Mapzen", { # Check data matches expectation skip_if(!file.exists(mapzen_tile[1])) elev_mapzen <- terra::rast(mapzen_tile[1]) - thumb_3 <- terra::aggregate(elev_mapzen, fact = 64) - expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) - expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) + thumb_2 <- terra::aggregate(elev_mapzen, fact = 64) # Run this code manually to update the "Expected" value if (FALSE) { terra::writeRaster( - thumb_3, overwrite = TRUE, + thumb_2, overwrite = TRUE, test_path("expected", "mapzen_pt.tif") ) } -}) + expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) + expect_true(all.equal(terra::rast(thumb_2), terra::rast(expected))) + +}) test_that("elev() downloads polygon from GeoData", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # polygon and geodata #### + # download mapzen using a polygon ### elev( - output_dir = tmp_dir, location = polygon, e_source = "geodata", quiet = TRUE + output_dir = tmp_dir, location = polygon_py_sm, e_source = "geodata", + quiet = TRUE ) srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(srtm_tile)) @@ -178,29 +175,31 @@ test_that("elev() downloads polygon from GeoData", { # Check data matches expectation skip_if(!file.exists(srtm_tile[1])) elev_srtm <- terra::rast(srtm_tile[1]) - thumb_2 <- terra::aggregate(elev_srtm, fact = 64) - expected <- terra::rast(test_path("expected", "srtm_py.tif")) - expect_true(all.equal(rast(thumb_2), terra::rast(expected))) + thumb_3 <- terra::aggregate(elev_srtm, fact = 64) # Run this code manually to update the "Expected" value if (FALSE) { terra::writeRaster( - thumb_2, overwrite = TRUE, + thumb_3, overwrite = TRUE, test_path("expected", "srtm_py.tif") ) } -}) + expected <- terra::rast(test_path("expected", "srtm_py.tif")) + expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) + +}) test_that("elev() downloads points from GeoData", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) elev( output_dir = tmp_dir, location = points, e_source = "geodata", quiet = TRUE ) + srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(srtm_tile)) @@ -208,8 +207,6 @@ test_that("elev() downloads points from GeoData", { skip_if(!file.exists(srtm_tile[1])) elev_srtm <- terra::rast(srtm_tile[1]) thumb_4 <- terra::aggregate(elev_srtm, fact = 64) - expected <- terra::rast(test_path("expected", "srtm_pt.tif")) - expect_true(all.equal(terra::rast(thumb_4), terra::rast(expected))) # Run this code manually to update the "Expected" value if (FALSE) { @@ -218,4 +215,8 @@ test_that("elev() downloads points from GeoData", { test_path("expected", "srtm_pt.tif") ) } + + expected <- terra::rast(test_path("expected", "srtm_pt.tif")) + expect_true(all.equal(terra::rast(thumb_4), terra::rast(expected))) + }) From c18e7c880f795b56fa93673c7dd0ff5d6cfd9241 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 17:53:18 +0200 Subject: [PATCH 43/61] adding new testing expectations --- tests/testthat/Rplots.pdf | Bin 8623 -> 3448 bytes tests/testthat/_snaps/elev.md | 5 +++-- tests/testthat/expected/island_srtm_py.tif | Bin 0 -> 28746 bytes tests/testthat/expected/mapzen_pt.tif | Bin 980 -> 980 bytes tests/testthat/expected/mapzen_py.tif | Bin 0 -> 1595 bytes tests/testthat/expected/srtm.tif | Bin 4886 -> 0 bytes tests/testthat/expected/srtm_pt.tif | Bin 2242 -> 2106 bytes tests/testthat/expected/srtm_py.tif | Bin 0 -> 2106 bytes 8 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 tests/testthat/expected/island_srtm_py.tif create mode 100644 tests/testthat/expected/mapzen_py.tif delete mode 100644 tests/testthat/expected/srtm.tif create mode 100644 tests/testthat/expected/srtm_py.tif diff --git a/tests/testthat/Rplots.pdf b/tests/testthat/Rplots.pdf index 6b7b7122210e569125be2b3eb8759ce5a969bde7..0a93a3d6020c32a064ac460285e3a284ad5c82f9 100644 GIT binary patch delta 179 zcmZ4Q{6lJjnX0*=nW4F{nW=#$m%eX)ic4Zis)B}#m63swu>o9eVsz!?rNRnau?qUm z`K5U!3I>yJ3;S%g6?wwNXg*n4K9-}RC^e1CK*3^ikb?8%rwU?r7M2PIAfS+^zy)R) q7#Ld`V2GI*8Ka9C8yZ?nPE?d;w3u9{sK#wQdFCz;UL!?LSPrfTlY`4cWyC;` zYZymOJ1hz;s(BF(g(IMU)lw~kaPnX%7-R1SQc?m#OoF^nV90el=ihf9lqVL9pp=ck z5Dkncma_B(EBsj-p?ooZJ`N~fu*~m-vN8ze>3F=)G2qXBAc!8y(;4dmhATi7z!0P> z8jJFwL^NdPuWvY_#<|-$c6Stb& zdNi-$i~HcU811g$+uKp$5$gLw1zlrjBsPBqTN$4u*o@P-ulI|W57uULFjaky3~sO~ zo3%FR%W_qrlg@O8*Q6l&=92WSRpL8_Gj1?DFe z-loSx%=A97m8aT3^Gq3uMh`}dUYfqTJ)<-u6*Q{ufH5;Di> zU_)3Q?@j|a(KLH8Hi7@+6)Kx~KE=;a3SsWGF$~3g?xW%~xg0_^qT%NTxkmHclR5sess0$ zib&J9ZlTMlSL`PuxT2+!fwOG>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Ql(CFavWP=M&RQU)(C8U>~;B3j4ycVksb#G2?xXAe~wZl0u1}(h7okA z$shm>mJVUG#{Dk;-9ST9%rY><*v}sO+fO@o)nH(VzMTifR-A?7e@4{#3Q#$U+xT~!0>$M_mtf)rP{zK(B*LHomy-nv3u_r5LH`5RH>%YD diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md index 4798e46..42715bc 100644 --- a/tests/testthat/_snaps/elev.md +++ b/tests/testthat/_snaps/elev.md @@ -3,7 +3,8 @@ Code elev(tmp_dir, sea, "GEOdata", quiet = TRUE) Warning - Coordinate reference system not specified; assuming EPSG:4326 - Could not download srtm_12_24: HTTP status 404 + Coordinate reference system not specified; assuming WGS84 + Could not download srtm__: HTTP status 404 Error No data downloaded. + diff --git a/tests/testthat/expected/island_srtm_py.tif b/tests/testthat/expected/island_srtm_py.tif new file mode 100644 index 0000000000000000000000000000000000000000..ccea4e98f1b9ddb2a41313e8e29901c0db51ebcd GIT binary patch literal 28746 zcmeHPdr(tX8vg=RL<53a@IfF%MCBQh00BwDOEDr4O?b%D5FSMh5s2~z%Ti*y)J3*y zyB(!Mc{nP9mUVargs!+gsi2|)T5Q3!Do7c$im(Tk&g$&Uy8k%S&U|+!IbU+l{hf19 zzH@T#Ilu2G6k5Vu09XV-(F6*ytjQZ?)(+MH(3rL9Bu{hJevjC5X6@;73@BOL}lYyrV`BiQZ)+k;?x66|#Zdp*JSCfFMYwvb?NB-lO#dlSL-CD?udU-$!5 zhyZFg1GH@c=oAC=O8_1P0K5nUm>UdWxD~)W1b`I^;1&kp7Y+~>0kAz1Aaxr+z7*iI zD1cHK87E|Ls$&2y#RA-p19)($d8b^_4l0Jda!xGKoY+sl2EZ;VnJEmcbS z^XPO}p)y8JPms!Ecnq<`T_O}qgr4F^U-w|4Z-6g@o-CE`+DY=53_hFbV9RDZah%y) zXGad#)o%LK|An#6-R}(m8)tI7{WPK9e^u>dZ|lr)a$vIT*^VssTOq^}FRyih|8L!1 z>%^X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JGwzUkwdUObCX%DU?=`)k_Vx5ss$T z*}^cImit47#yj>*jIP00BaFPlI5dpP!x%-3*u?l%j93nL_mcI z)XPBi5Y$pZWf|1jLDeDDU_wPI)aOFAGSqHEB|FshLzP3+d_>JhRKP?%P*g`ntyomf yMIB*ORYr|zRNO}Waa3bRZF*GdM`krLtC3la%xYv-BeNQr)yS+yX7wA)>VE;`F%!c8 literal 0 HcmV?d00001 diff --git a/tests/testthat/expected/mapzen_pt.tif b/tests/testthat/expected/mapzen_pt.tif index de2524481becf9134bb80f5b8967235cce8af3e4..4801eb6fb114c97bf2ad51c0ca46f67ebb2816c1 100644 GIT binary patch delta 25 gcmcb@euaI5ITMemK}xc5N~)!?g@NH_XQqja0B9`-V*mgE delta 25 gcmcb@euaI5ITMeWaiW2Fs)dQMNuuRuXQqja0A&3KIRF3v diff --git a/tests/testthat/expected/mapzen_py.tif b/tests/testthat/expected/mapzen_py.tif new file mode 100644 index 0000000000000000000000000000000000000000..3811eeea303d2cde434b57df3882290af3b50625 GIT binary patch literal 1595 zcmebD)MDUZU|<_5Bvplk&on;FVx1+v+oY>*y7Mi#K%e@sCA zNaA8pHpm=ts2W>l1_l`}?gn_S_hXF*#0nKb`;bC9{vde(%_3g|I3PAQU zAbUeQ4+D^5cm^akwljf!@(svtSi;1R4RqKipj;!6%>tzJ67zs01A~pbi=&TkYDr>B zVo9PMmx6+gXGvVs1eWP|iTfPS?o9 zz*x`J!py|T)ZD_**hU|u7oQ=nj((^nSONiIZJvIZb{kum80eW98kw3{SQuFt5;P<@ z#Kpxmj9A-UT!Wp1JOe^J{ZSmOP?QhydrE3?a#3bMNoIbYl3iM6PO7OvO0uDuX`+b% zA{1=&QG=F&p=yQT1lPkC?HiypI0Enx|3Tn)lEWljmkk;jz6W4R8NsQGodFb)jKCNN zCM6&Zj9_5WWn_3Jz{s(&9VpAd2IluEb8>8G2g!4TX$FRl+>&XsONtzTN*tDjL^y`K z2P;^Z)G#zyOlTIytL70Id7Iuz+sJqq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s>m}Dg=R<6tM2VCSVg?qQ|UE=mtsf z(JcWJn3xy-;7A+8a+tU0qQIeKD2x<Egkn7sAQux8g4kt_~Dvuc_-duf-5w=L< zK#SX!D+Mdva=0227#L!0WEe_h2GFp&QHDQd>W|4tIv)G{A^*>kMHXr&u)FNIJ@en$#+@pLrdN?8k-P{)sJXf z4<;_LDC!(`e%n|fwBO$~Lf>|9B%M)lbIj%6Cye*=8hR#Na}kpbm9YdQu^1`hwc6G(kBhJ?^x2?D~oavd@AIDJiB)P6`v)S%n-#50! zOA>xK>cqfCx5&2o3rVNHf0DgS(*Ib}Hk9tMrrqX4ap$Aw+r0CIR*G-OGQHNeH!N@H zpLm(e$iExccK>;{chm*j?N>)$yp=Gw3lHCa`Zkxj?kp8Iwy5Il+ diff --git a/tests/testthat/expected/srtm_pt.tif b/tests/testthat/expected/srtm_pt.tif index 9ebbc0c511e55102e26e2ae42a2190178f92a45c..d5d474df89686a99bf3f5ab75dac49cc51732401 100644 GIT binary patch delta 220 zcmX>kxJzKdqWUx@28N~<9tJiB28KEydwn}Ig94Df4#?in&cgtt7~TPijqOYf96 zg@EjaB}@znj0_A?K->sqvjD~O67zs01H%NMm<$p=0u+-1>RAO;bc~gO;StcHf9wnl zHtsHtKEA1w6&X$WERFOG&CQKW%nU4z%}pmWGKo#jXAI*tG}ALNFgG$XGc_}UiE>YV z$r#6KY!+{5G}(tqlG9)M#g<0D)%O0A^O#n0k>*Lpk=Y(;6Z9AE~IVxvcz$b^M1J2DF3k!d8Hk>h zozCR&!GxLR;Di`i7RL`Eikyc6)<|D*ylh diff --git a/tests/testthat/expected/srtm_py.tif b/tests/testthat/expected/srtm_py.tif new file mode 100644 index 0000000000000000000000000000000000000000..d5d474df89686a99bf3f5ab75dac49cc51732401 GIT binary patch literal 2106 zcmebD)MDUZU|-pD0L7W1Y*rwf4ax@T5oBaxfQT_Lh$4xL zLD`}}HR4b;pMY!`BsI23>|iLH8K{P@nTG*Hr!g@wG_~+BumRb1K=%4}W(EZydmWIy zp`C{TNHM$v5*yo@z&`m0WH&5fV(mbo0xGft zdLjyFQ5ib}gN?h3qmOTDNn%Q3NunK>f`W}_NouY_USe*ltx|A^V~A&Ph^KRKysu+~ zr*EjQl0tD}Zb1%E&OpfyXqSyXNI5=zu8w{vnshCJfUq`CKeDU~4smgD4I|b<7uR6t zAkTmhPk$6QDiq~|e3+72oLrPyP?DLSr({=LRFWHSW)W{>0&}~KK5Ebb!&3UimPWtT z_CZh@91(k_PVsFr|#(6bg(SU|cZ*V;-2KfHW{dfk~K=;h6v<$HsP`ECU;u z->1yUv7sF#&kd#-7&>xGrpYcTasVoESQZlD815ddU|~|j(7?dJ!~BPfldb8%LxYMC zC0X7MXQhB0OYGFex{f3pR$NK4m7UP&RuQNiBzM?kVUb&GrZM;b}reMZZ_*o zx^d-|N42&K{567isr+kqTXZ4Qq$*TtuJ4Lqt&m+y?UskFx{_^Lbv0>k?1pfi(A}za z$I~|5$Th1DU352hN3>qp?xp*lm+iWfZ(e=%(cjtw@dn|0RR6QL9ePk`Q4^*t+j}C} zC}Phtd-Z9jo)lZwTuZi{dm-HWciH~*ZMWW(Ti0HD zT)X!{zD4vtwg2tM9(|~^sS8)0d-g@KRm{HS_RFum`ciFMcRhLU-4Eq9vHR8Qk3akL rqt>oIeDU44KdSBG_AlT6{M)ZTSrY_C!)7#WM$^q`oaszO)*{vjgk literal 0 HcmV?d00001 From d72a2a48996f4f5ac4b701afc79333d4b4ed9cc6 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 19:01:39 +0200 Subject: [PATCH 44/61] fixing importFrom "crs<-" to "crs" adding "mask" to imports --- NAMESPACE | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 6cf4741..fc776d8 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -42,11 +42,12 @@ importFrom(sp,SpatialPointsDataFrame) importFrom(sp,SpatialPolygonsDataFrame) importFrom(stats,aggregate) importFrom(stats,sd) -importFrom(terra,"crs<-") importFrom(terra,centroids) importFrom(terra,colFromCell) importFrom(terra,crds) +importFrom(terra,crs) importFrom(terra,extract) +importFrom(terra,mask) importFrom(terra,mosaic) importFrom(terra,rast) importFrom(terra,rasterize) From cc9e4d3bddeb0259f6bc6d7bd0af504a30d1be1c Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 19:02:01 +0200 Subject: [PATCH 45/61] imports --- R/elev.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/elev.R b/R/elev.R index 2c0118a..fe164e1 100644 --- a/R/elev.R +++ b/R/elev.R @@ -1,4 +1,4 @@ -#' @importFrom terra colFromCell crs<- rowFromCell +#' @importFrom terra colFromCell crs rowFromCell mask .elev_geodata <- function(location, output_dir, ...) { # create SRTM tiles @@ -22,6 +22,7 @@ on.exit(unlink(temp_file)) srtm_list <- lapply(srtm_id, function(id) { + print(id) tif <- paste0(output_dir, "/", id, ".tif") error <- if (file.exists(tif)) { 0 From 8e63885633d0693d8fb49036d82edc46dfe8d753 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 19:02:26 +0200 Subject: [PATCH 46/61] reducing size of testing polygon further --- tests/testthat/expected/mapzen_pt.tif | Bin 980 -> 980 bytes tests/testthat/expected/mapzen_py.tif | Bin 1595 -> 990 bytes tests/testthat/test-elev.R | 23 ++++++++++++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/testthat/expected/mapzen_pt.tif b/tests/testthat/expected/mapzen_pt.tif index 4801eb6fb114c97bf2ad51c0ca46f67ebb2816c1..319d80d378a924d9f510d7673cda58b80bbef99a 100644 GIT binary patch delta 25 gcmcb@euaI5ITMdjN|K48xw)}XN@B`pXQqja0B8OOj{pDw delta 25 gcmcb@euaI5ITMemK}xc5N~)!?g@NH_XQqja0B9`-V*mgE diff --git a/tests/testthat/expected/mapzen_py.tif b/tests/testthat/expected/mapzen_py.tif index 3811eeea303d2cde434b57df3882290af3b50625..f1087cd9d481dd1e9264a38969386793c353f589 100644 GIT binary patch delta 398 zcmdnZbB|r#(^HFqgMooTn1O+jnSl|=;s#Qm;Q@m?e?a)-Ia z_S%HD*OwYPs`w<nNrGuKr}`Uy&`Ph^#exxA{Mr;y=;S>OAt e00urD?T#ttyW~Ghuj+eWyZ3?D_CI=@|Cj)_o{xV3 delta 1008 zcmVjkX7AZlPBw~^oVTLH=99&|p!X`#3pe9*j zzMO>?D$Np1Vy2Fy_A5NhNn(^u5`r@_P>L8y1CGKo6_%GEu}ID7%5_aBL?C9XqnQ1Q zJbH^*pa25^{#z@-3=UdTc@`sLsEmQeD`_lVV!Oa5HY-dI90P{Sx-#d^C1 z5K`nZs=OIx0Vf71%}P^ZuS5ho%F|M?72pU=ouSO7C>}bmkMX4Cnl&7;SqJgc6_QJw zh8!65iZpP=4z2{Wx@r9e*B7x|f5gZk-DyfrI-v$3$XSXwb=u4flG_#h7TOpc!^SG4 zNTUG91Nc@KB0-8B5KI6*P=}@{1~fl_*%=0s=Gu%#AL*%*4Ke3=LZveU`DQICMWK`q zn598XgabyC%e?7|YH>n2>A zv^nS}Fo1v*!U2RsCJ~gZm_P-FrYUq8Adv_}D7+w9hclbw*iA$nlW+)g)}UYn47MSB zP%<7hIeK*kEGYE)hUVh%35Se8fAZCD~r^m}k{v5Sv9iwq>8nQ93%a;{Yrh7^NuM@Pey*eRKjc_K(KhOtJ;k%syRaE7fJ&StQIx!;Hbr>#zC1ohym e7*~-GJnr-AcS1k(eJ?@N^j$|u)pXrToPdBPzlnta diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 6a2e9c2..1b31e39 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -7,11 +7,15 @@ sf::st_crs(polygon_py) <- "epsg:4326" points <- terra::centroids(terra::vect(polygon_py)) polygon_py_sm <- sf::st_polygon( - list(cbind(long = c(156, 156, 154, 156), - lat = c(-61, -60, -61, -61))) + list(cbind(long = c(156, 156, 155, 156), + lat = c(-60, -59, -60, -60))) ) polygon_py_sm <- sf::st_geometry(polygon_py_sm) sf::st_crs(polygon_py_sm) <- "epsg:4326" +points_sm <- terra::centroids(terra::vect(polygon_py_sm)) + +#terra::plot(climenv::srtm_tiles[srtm_tiles$FID %in% c(827, 828),], col = 'red') +#terra::plot(polygon_py_sm, add = TRUE) scrub_progress_bars <- function(x) { progress_bars <- grep("^[\\|\\-=\\s]*$", x, perl = TRUE) @@ -164,11 +168,19 @@ test_that("elev() downloads polygon from GeoData", { tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) - # download mapzen using a polygon ### + # download srtm using a polygon ### elev( - output_dir = tmp_dir, location = polygon_py_sm, e_source = "geodata", + output_dir = tmp_dir, location = polygon_py_sm, + e_source = "geodata", quiet = TRUE ) + + + output_dir = tmp_dir; location = polygon_py_sm; + e_source = "geodata"; + quiet = TRUE + location = location_sf + srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(srtm_tile)) @@ -197,7 +209,8 @@ test_that("elev() downloads points from GeoData", { on.exit(unlink(tmp_dir)) elev( - output_dir = tmp_dir, location = points, e_source = "geodata", quiet = TRUE + output_dir = tmp_dir, location = points_sm, e_source = "geodata", + quiet = TRUE ) srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") From 44b8f705e94509823ed429533aaa232ebc1afc32 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Sun, 16 Jul 2023 19:20:05 +0200 Subject: [PATCH 47/61] updating ce_extract to issue warning when no `location_g` argument supplied. --- R/ce_extract.R | 2 +- man-roxygen/output_location_g_param.R | 3 ++- tests/testthat/test-extract.R | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/R/ce_extract.R b/R/ce_extract.R index 3f23961..be97cd6 100644 --- a/R/ce_extract.R +++ b/R/ce_extract.R @@ -287,7 +287,7 @@ # Assigns an 'id' if location_g is empty if (is.null(location_g)) { - message( + warning( paste( "location_g must be one of", paste(setdiff(colnames(location_df), c("coords.x1", "coords.x2")), diff --git a/man-roxygen/output_location_g_param.R b/man-roxygen/output_location_g_param.R index 9fec503..78b5dbd 100644 --- a/man-roxygen/output_location_g_param.R +++ b/man-roxygen/output_location_g_param.R @@ -1,3 +1,4 @@ #' @param location_g Character. Informs how the zonal statistics are exported. #' Must correspond to a column of the `"location"` argument. If NULL, -#' the zonal statistics are calculated for all features of `"location"`. +#' the zonal statistics are calculated for all features of `"location"` and a +#' warning issued. diff --git a/tests/testthat/test-extract.R b/tests/testthat/test-extract.R index 71d16c8..40361f1 100644 --- a/tests/testthat/test-extract.R +++ b/tests/testthat/test-extract.R @@ -255,6 +255,11 @@ test_that("ce_extract() works", { location_g = "grp", location_df = location_df) ) + expect_warning( + .location_helper(location = pol_pt, + location_g = NULL, + location_df = location_df) + ) # .c_source_helper expect_no_error(.c_source_helper(c_source = "CHELSA")) From eac461d54ab061151d5e764fc320c7bbe73e7eb0 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:27:00 +0100 Subject: [PATCH 48/61] Return FALSE if no valid tiles --- R/elev.R | 26 ++++++++++++++++++-------- man/ce_extract.Rd | 3 ++- man/elev.Rd | 2 ++ tests/testthat/_snaps/elev.md | 10 ---------- tests/testthat/test-elev.R | 5 ++--- 5 files changed, 24 insertions(+), 22 deletions(-) delete mode 100644 tests/testthat/_snaps/elev.md diff --git a/R/elev.R b/R/elev.R index fe164e1..43c9ece 100644 --- a/R/elev.R +++ b/R/elev.R @@ -13,6 +13,9 @@ tiles <- unique( terra::extract(rs, location, touches = TRUE)$lyr.1 ) + if (all(is.na(tiles))) { + return(NULL) + } cols <- formatC(terra::colFromCell(rs, tiles), width = 2, flag = 0) rows <- formatC(terra::rowFromCell(rs, tiles), width = 2, flag = 0) na <- cols == "NA" | rows == "NA" @@ -87,6 +90,8 @@ #' @param \dots Additional arguments to [`download.file()`]. #' #' @return +#' `elev()` is called for its side-effects. +#' It returns `TRUE` if files were downloaded successfully, `FALSE` otherwise. #' Creates one subfolder named elev storing a raster (.tiff). If elevation is #' sourced from geodata the elevation is downloaded at a spatial resolution of #' 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the @@ -190,16 +195,21 @@ elev <- function(output_dir, location, e_source = "mapzen", file_path <- paste0(output_dir, "/elev/srtm.tif") # Saves elevation from geodata or mapzen sources switch(e_source_id, { # mapzen - elev_raster <- elevatr::get_elev_raster( - location_sf, z = 7, override_size_check = TRUE, - progress = verbose, verbose = verbose - ) - srtm_mosaic <- as(elev_raster, "SpatRaster") - terra::writeRaster(srtm_mosaic, filename = file_path, - overwrite = TRUE) + elev_raster <- elevatr::get_elev_raster( + location_sf, z = 7, override_size_check = TRUE, + progress = verbose, verbose = verbose + ) + srtm_mosaic <- as(elev_raster, "SpatRaster") + terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) + TRUE }, { # geodata srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) - terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) + if (is.null(srtm_mosaic)) { + FALSE + } else { + terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) + TRUE + } } ) } diff --git a/man/ce_extract.Rd b/man/ce_extract.Rd index d595c7e..b948d39 100644 --- a/man/ce_extract.Rd +++ b/man/ce_extract.Rd @@ -25,7 +25,8 @@ objects.} \item{location_g}{Character. Informs how the zonal statistics are exported. Must correspond to a column of the \code{"location"} argument. If NULL, -the zonal statistics are calculated for all features of \code{"location"}.} +the zonal statistics are calculated for all features of \code{"location"} and a +warning issued.} \item{c_source}{Character (e.g., \code{"CHELSA or WorldClim"}). Indicating the climate data source.} diff --git a/man/elev.Rd b/man/elev.Rd index c15eb1f..c662dbc 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -23,6 +23,8 @@ downloading from Mapzen.} \item{\dots}{Additional arguments to \code{\link[=download.file]{download.file()}}.} } \value{ +\code{elev()} is called for its side-effects. +It returns \code{TRUE} if files were downloaded successfully, \code{FALSE} otherwise. Creates one subfolder named elev storing a raster (.tiff). If elevation is sourced from geodata the elevation is downloaded at a spatial resolution of 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the diff --git a/tests/testthat/_snaps/elev.md b/tests/testthat/_snaps/elev.md deleted file mode 100644 index 42715bc..0000000 --- a/tests/testthat/_snaps/elev.md +++ /dev/null @@ -1,10 +0,0 @@ -# elev() fails gracefully - - Code - elev(tmp_dir, sea, "GEOdata", quiet = TRUE) - Warning - Coordinate reference system not specified; assuming WGS84 - Could not download srtm__: HTTP status 404 - Error - No data downloaded. - diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 1b31e39..197de0b 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -62,9 +62,8 @@ test_that("elev() fails gracefully", { sea <- sf::st_as_sf( data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) - expect_snapshot(elev(tmp_dir, sea, "GEOdata", quiet = TRUE), - cran = TRUE, error = TRUE, scrub_progress_bars) - + sf::st_crs(sea) <- "wgs84" + expect_false(elev(tmp_dir, sea, "GEOdata", quiet = TRUE)) }) test_that("elev() downloads tiles not containing a vertex srtm", { From 561230e92b45588e3f48c9ab809cedae87180e10 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:28:12 +0100 Subject: [PATCH 49/61] * remove scrub_progress_bars now uncalled --- tests/testthat/test-elev.R | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 197de0b..55a1447 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -17,15 +17,6 @@ points_sm <- terra::centroids(terra::vect(polygon_py_sm)) #terra::plot(climenv::srtm_tiles[srtm_tiles$FID %in% c(827, 828),], col = 'red') #terra::plot(polygon_py_sm, add = TRUE) -scrub_progress_bars <- function(x) { - progress_bars <- grep("^[\\|\\-=\\s]*$", x, perl = TRUE) - if (length(progress_bars)) { - x[-progress_bars] - } else { - x - } -} - skip_if_server_offline <- function(server) { # Preferred to testthat::skip_if_offline as this runs on CRAN # Thus we can expect notice of any breaking changes to imported packages From a6d1327cb7cec0cad3765512dd66a186b970835c Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:29:46 +0100 Subject: [PATCH 50/61] use https:// for checks --- tests/testthat/test-elev.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index 55a1447..ed80953 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -32,7 +32,7 @@ skip_if_server_offline <- function(server) { test_that("elev() fails gracefully", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("https://srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) @@ -59,7 +59,7 @@ test_that("elev() fails gracefully", { test_that("elev() downloads tiles not containing a vertex srtm", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("https://srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) @@ -154,7 +154,7 @@ test_that("elev() downloads points from Mapzen", { test_that("elev() downloads polygon from GeoData", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("https://srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) @@ -194,7 +194,7 @@ test_that("elev() downloads polygon from GeoData", { test_that("elev() downloads points from GeoData", { - skip_if_server_offline("srtm.csi.cgiar.org") + skip_if_server_offline("https://srtm.csi.cgiar.org") tmp_dir <- tempdir() on.exit(unlink(tmp_dir)) From 7a8d71e57904872bac6c45ab2064c4df30c42855 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:35:10 +0100 Subject: [PATCH 51/61] distinct temp_file for each loop Inreased robustness to file permission errors --- R/elev.R | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/R/elev.R b/R/elev.R index 43c9ece..8fb5b3f 100644 --- a/R/elev.R +++ b/R/elev.R @@ -21,11 +21,11 @@ na <- cols == "NA" | rows == "NA" srtm_id <- paste0("srtm_", cols[!na], "_", rows[!na]) - temp_file <- tempfile("srtm_", output_dir) - on.exit(unlink(temp_file)) - srtm_list <- lapply(srtm_id, function(id) { - print(id) + + temp_file <- tempfile("srtm_", output_dir) + on.exit(unlink(temp_file)) + tif <- paste0(output_dir, "/", id, ".tif") error <- if (file.exists(tif)) { 0 From 42c2ea007eddc1ddfef88d8deae0ded01d5484c5 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:35:14 +0100 Subject: [PATCH 52/61] indent --- tests/testthat/test-elev.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index ed80953..fd04e49 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -70,7 +70,7 @@ test_that("elev() downloads tiles not containing a vertex srtm", { # downloading the data for srtm expect_warning( - geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), + geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), "Coordinate reference system not specified") thumb_0 <- terra::aggregate(geo_elev, fact = 20) From 130b797a6d491972df17c9eb2d7d0811885bed35 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:46:32 +0100 Subject: [PATCH 53/61] Only unzip if file downloaded --- R/elev.R | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/R/elev.R b/R/elev.R index 8fb5b3f..dce0c3a 100644 --- a/R/elev.R +++ b/R/elev.R @@ -36,22 +36,31 @@ ) url_status <- attr(curlGetHeaders(zip_url, verify = FALSE), "status") error <- if (url_status == 200) { - tryCatch( + if (tryCatch( utils::download.file(url = zip_url, destfile = temp_file, mode = "wb", ...), # Returns 0 on success error = function(e) { warning("Failed to download ", id, ": ", e) -1 # Error code } - ) + ) == 0) { + if (isFALSE(tryCatch( + utils::unzip(temp_file, paste0(id, ".tif"), exdir = output_dir), + error = function(e) { + warning("Temporary file not found: ", temp_file) + FALSE + }))) { + -2 # Error code + } else { + 0 # Success code + } + } } else { warning("Could not download ", id, ": HTTP status ", url_status) -1 } } if (error == 0) { - tryCatch(utils::unzip(temp_file, paste0(id, ".tif"), exdir = output_dir), - error = function(e) warning("Failed to unzip: ", id)) rs <- terra::rast(tif) terra::crs(rs) <- "+proj=longlat +datum=WGS84" rs From 2feafd4726ff71a1af31849d6c696cb18ffd030a Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:47:08 +0100 Subject: [PATCH 54/61] make `TRUE` return invisible --- R/elev.R | 7 ++++--- man/elev.Rd | 3 ++- tests/testthat/test-elev.R | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/R/elev.R b/R/elev.R index dce0c3a..da9a1bf 100644 --- a/R/elev.R +++ b/R/elev.R @@ -100,7 +100,8 @@ #' #' @return #' `elev()` is called for its side-effects. -#' It returns `TRUE` if files were downloaded successfully, `FALSE` otherwise. +#' It invisibly returns `TRUE` if files were downloaded successfully, +#' and returns `FALSE` otherwise. #' Creates one subfolder named elev storing a raster (.tiff). If elevation is #' sourced from geodata the elevation is downloaded at a spatial resolution of #' 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the @@ -210,14 +211,14 @@ elev <- function(output_dir, location, e_source = "mapzen", ) srtm_mosaic <- as(elev_raster, "SpatRaster") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) - TRUE + invisible(TRUE) }, { # geodata srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) if (is.null(srtm_mosaic)) { FALSE } else { terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) - TRUE + invisible(TRUE) } } ) diff --git a/man/elev.Rd b/man/elev.Rd index c662dbc..317c03c 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -24,7 +24,8 @@ downloading from Mapzen.} } \value{ \code{elev()} is called for its side-effects. -It returns \code{TRUE} if files were downloaded successfully, \code{FALSE} otherwise. +It invisibly returns \code{TRUE} if files were downloaded successfully, +and returns \code{FALSE} otherwise. Creates one subfolder named elev storing a raster (.tiff). If elevation is sourced from geodata the elevation is downloaded at a spatial resolution of 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index fd04e49..f1f4174 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -159,17 +159,17 @@ test_that("elev() downloads polygon from GeoData", { on.exit(unlink(tmp_dir)) # download srtm using a polygon ### - elev( + expect_true(elev( output_dir = tmp_dir, location = polygon_py_sm, e_source = "geodata", quiet = TRUE - ) output_dir = tmp_dir; location = polygon_py_sm; e_source = "geodata"; quiet = TRUE location = location_sf + )) srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(srtm_tile)) From 1d36ef93cfcfad9a883e70c14ecf8da6076e3efa Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:59:12 +0100 Subject: [PATCH 55/61] Return "SpatRaster" --- R/elev.R | 12 ++++++------ man/elev.Rd | 4 ++-- tests/testthat/test-elev.R | 19 +++++++------------ 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/R/elev.R b/R/elev.R index da9a1bf..07d5e50 100644 --- a/R/elev.R +++ b/R/elev.R @@ -98,10 +98,12 @@ #' downloading from Mapzen. #' @param \dots Additional arguments to [`download.file()`]. #' -#' @return +#' @returns #' `elev()` is called for its side-effects. -#' It invisibly returns `TRUE` if files were downloaded successfully, -#' and returns `FALSE` otherwise. +#' It invisibly returns a "SpatRaster" object if files were downloaded +#' successfully, and returns `NULL` otherwise. +# TODO James please describe the contents of the SpatRaster object that is +# returned #' Creates one subfolder named elev storing a raster (.tiff). If elevation is #' sourced from geodata the elevation is downloaded at a spatial resolution of #' 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the @@ -211,14 +213,12 @@ elev <- function(output_dir, location, e_source = "mapzen", ) srtm_mosaic <- as(elev_raster, "SpatRaster") terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) - invisible(TRUE) }, { # geodata srtm_mosaic <- .elev_geodata(location_sf, output_dir, ...) if (is.null(srtm_mosaic)) { - FALSE + NULL } else { terra::writeRaster(srtm_mosaic, filename = file_path, overwrite = TRUE) - invisible(TRUE) } } ) diff --git a/man/elev.Rd b/man/elev.Rd index 317c03c..15d07be 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -24,8 +24,8 @@ downloading from Mapzen.} } \value{ \code{elev()} is called for its side-effects. -It invisibly returns \code{TRUE} if files were downloaded successfully, -and returns \code{FALSE} otherwise. +It invisibly returns a "SpatRaster" object if files were downloaded +successfully, and returns \code{NULL} otherwise. Creates one subfolder named elev storing a raster (.tiff). If elevation is sourced from geodata the elevation is downloaded at a spatial resolution of 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index f1f4174..d02b213 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -54,7 +54,7 @@ test_that("elev() fails gracefully", { data.frame(lat = c(-59, -59, -58, -59), lng = c(-123, -124, -123, -123)), coords = 2:1) sf::st_crs(sea) <- "wgs84" - expect_false(elev(tmp_dir, sea, "GEOdata", quiet = TRUE)) + expect_null(elev(tmp_dir, sea, "GEOdata", quiet = TRUE)) }) test_that("elev() downloads tiles not containing a vertex srtm", { @@ -71,7 +71,8 @@ test_that("elev() downloads tiles not containing a vertex srtm", { # downloading the data for srtm expect_warning( geo_elev <- elev(tmp_dir, island, "GEOdata", quiet = TRUE), - "Coordinate reference system not specified") + "Coordinate reference system not specified" + ) thumb_0 <- terra::aggregate(geo_elev, fact = 20) @@ -128,9 +129,9 @@ test_that("elev() downloads points from Mapzen", { on.exit(unlink(tmp_dir)) # download mapzen using points - elev( + expect_true(inherits(elev( output_dir = tmp_dir, location = points, e_source = "mapzen" - ) + ), "SpatRaster")) mapzen_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(mapzen_tile)) @@ -159,17 +160,11 @@ test_that("elev() downloads polygon from GeoData", { on.exit(unlink(tmp_dir)) # download srtm using a polygon ### - expect_true(elev( + expect_true(inherits(elev( output_dir = tmp_dir, location = polygon_py_sm, e_source = "geodata", quiet = TRUE - - - output_dir = tmp_dir; location = polygon_py_sm; - e_source = "geodata"; - quiet = TRUE - location = location_sf - )) + ), "SpatRaster")) srtm_tile <- paste0(tmp_dir, "/elev/srtm.tif") expect_true(file.exists(srtm_tile)) From 41a7f51a34b4652035fab32a7f84af7734bc9139 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 08:59:21 +0100 Subject: [PATCH 56/61] skip_if_server_offline return invisibly --- tests/testthat/test-elev.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index d02b213..dd0f3c6 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -20,14 +20,14 @@ points_sm <- terra::centroids(terra::vect(polygon_py_sm)) skip_if_server_offline <- function(server) { # Preferred to testthat::skip_if_offline as this runs on CRAN # Thus we can expect notice of any breaking changes to imported packages - tryCatch( + invisible(tryCatch( curlGetHeaders(server, timeout = 2), error = function(e) { if (length(grep("Connection timed out", e$message, fixed = TRUE))) { testthat::skip(paste("Could not connect to", server)) } } - ) + )) } test_that("elev() fails gracefully", { From eb15fb46cf54c42a2192bcba29ae060ec92e5777 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:04:53 +0100 Subject: [PATCH 57/61] Don't compare names Names are names of temporary files created by rast (I think) --- tests/testthat/test-elev.R | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index dd0f3c6..aa47ad5 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -118,7 +118,10 @@ test_that("elev() downloads polygon from Mapzen", { } expected <- terra::rast(test_path("expected", "mapzen_py.tif")) - expect_true(all.equal(terra::rast(thumb_1), terra::rast(expected))) + expect_true(all.equal( + unname(terra::rast(thumb_1)), + unname(terra::rast(expected)) + )) }) @@ -149,7 +152,10 @@ test_that("elev() downloads points from Mapzen", { } expected <- terra::rast(test_path("expected", "mapzen_pt.tif")) - expect_true(all.equal(terra::rast(thumb_2), terra::rast(expected))) + expect_true(all.equal( + unname(terra::rast(thumb_2)), + unname(terra::rast(expected)) + )) }) @@ -183,7 +189,10 @@ test_that("elev() downloads polygon from GeoData", { } expected <- terra::rast(test_path("expected", "srtm_py.tif")) - expect_true(all.equal(terra::rast(thumb_3), terra::rast(expected))) + expect_true(all.equal( + unname(terra::rast(thumb_3)), + unname(terra::rast(expected)) + )) }) @@ -215,6 +224,9 @@ test_that("elev() downloads points from GeoData", { } expected <- terra::rast(test_path("expected", "srtm_pt.tif")) - expect_true(all.equal(terra::rast(thumb_4), terra::rast(expected))) + expect_true(all.equal( + unname(terra::rast(thumb_4)), + unname(terra::rast(expected)) + )) }) From db33f92a18506c6f7ffe32779ed5743d56b64bb5 Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:14:34 +0100 Subject: [PATCH 58/61] Update tests: Warn, don't message --- tests/testthat/test-extract.R | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/tests/testthat/test-extract.R b/tests/testthat/test-extract.R index 40361f1..f478608 100644 --- a/tests/testthat/test-extract.R +++ b/tests/testthat/test-extract.R @@ -3,6 +3,7 @@ test_that("ce_extract() works", { # Create temporary file to supply to the ce_extract temp_path <- tempfile() + on.exit(unlink(file.path(temp_path)), add = TRUE) # Create the required subdirectories dir.create(file.path(temp_path, "/elev"), recursive = TRUE) @@ -10,7 +11,6 @@ test_that("ce_extract() works", { dir.create(file.path(temp_path, "/tmax"), recursive = TRUE) dir.create(file.path(temp_path, "/tavg"), recursive = TRUE) dir.create(file.path(temp_path, "/tmin"), recursive = TRUE) - on.exit(unlink(file.path(temp_path)), add = TRUE) # Create a empty raster serving as a base r <- terra::rast(ncol = 10, nrow = 10) @@ -68,14 +68,15 @@ test_that("ce_extract() works", { #** No location group #### - #* default messages when no id provided #### - expect_silent(expect_message({ + #* default warning when no location_g provided #### + expect_silent(expect_warning( data_py <- ce_extract( path = file.path(temp_path), location = pol_py, location_g = NULL, c_source = "WorldClim", var = "all" - ) - })) + ), + "location_g must be one of: " + )) #* length / names of output data.frames #### expect_named(data_py, c("tavg_m", "tavg_sd", "tmin_m", "abmt", "tmin_sd", @@ -148,13 +149,14 @@ test_that("ce_extract() works", { #** No location group #### #* default messages when no id provided #### - expect_message({ + expect_warning( data_pt <- ce_extract( path = file.path(temp_path), location = pol_pt, location_g = NULL, c_source = "WorldClim", var = "all" - ) - }) + ), + "location_g must be one of: " + ) #* length / names of output data.frames #### expect_named(data_pt, c("tavg", "tmin", "tmax", From 304a0fa533255d44fc899031573238c90e3fa21a Mon Sep 17 00:00:00 2001 From: "Martin R. Smith" <1695515+ms609@users.noreply.github.com> Date: Mon, 17 Jul 2023 09:21:53 +0100 Subject: [PATCH 59/61] Remove commented code Required by lint --- tests/testthat/test-elev.R | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/testthat/test-elev.R b/tests/testthat/test-elev.R index aa47ad5..fb980b6 100644 --- a/tests/testthat/test-elev.R +++ b/tests/testthat/test-elev.R @@ -14,9 +14,6 @@ polygon_py_sm <- sf::st_geometry(polygon_py_sm) sf::st_crs(polygon_py_sm) <- "epsg:4326" points_sm <- terra::centroids(terra::vect(polygon_py_sm)) -#terra::plot(climenv::srtm_tiles[srtm_tiles$FID %in% c(827, 828),], col = 'red') -#terra::plot(polygon_py_sm, add = TRUE) - skip_if_server_offline <- function(server) { # Preferred to testthat::skip_if_offline as this runs on CRAN # Thus we can expect notice of any breaking changes to imported packages From eca97e9ad7cfde5a5eaec6dc45433aa5d5966587 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Mon, 17 Jul 2023 15:21:54 +0200 Subject: [PATCH 60/61] updating returns descriptions on functions. --- R/ce_download.R | 2 +- R/ce_extract.R | 2 +- R/chelsa.R | 2 +- R/elev.R | 27 +++++++++++++-------------- R/plot_c.R | 13 +++++++------ R/plot_h.R | 3 ++- R/plot_wl.R | 8 ++++---- man/elev.Rd | 24 ++++++++++++------------ man/plot_c.Rd | 12 ++++++------ man/plot_wl.Rd | 7 +++---- 10 files changed, 50 insertions(+), 50 deletions(-) diff --git a/R/ce_download.R b/R/ce_download.R index d3c756e..f516724 100644 --- a/R/ce_download.R +++ b/R/ce_download.R @@ -12,7 +12,7 @@ #' @param \dots Arguments to control a download from the Internet #' `download.file()`. #' -#' @return +#' @returns #' See documentation from [`chelsa()`], [`worldclim()`] and #' [`elev()`]. #' diff --git a/R/ce_extract.R b/R/ce_extract.R index be97cd6..cdea05d 100644 --- a/R/ce_extract.R +++ b/R/ce_extract.R @@ -347,7 +347,7 @@ #' @template output_c_source_param #' @template output_var_param #' -#' @return +#' @returns #' Returns a list storing matrices containing the mean and standard deviation #' of the climate and/or elevation data. Each column represents a month, each #' row represents a feature of the \code{location} \code{sp}, \code{sf} polygon diff --git a/R/chelsa.R b/R/chelsa.R index 4a4a622..f62988e 100644 --- a/R/chelsa.R +++ b/R/chelsa.R @@ -10,7 +10,7 @@ #' @param quiet,\dots Arguments to control a download from the Internet #' `download.file()`. #' -#' @return +#' @returns #' Returns four subfolders named prec, tmax, tmin and tmean. Each folder #' contains 12 GeoTiff (.tif) files, one for each month of the year for the time #' period 1981–2010. Each of the files are downloaded at a spatial diff --git a/R/elev.R b/R/elev.R index 07d5e50..f1afaab 100644 --- a/R/elev.R +++ b/R/elev.R @@ -101,18 +101,16 @@ #' @returns #' `elev()` is called for its side-effects. #' It invisibly returns a "SpatRaster" object if files were downloaded -#' successfully, and returns `NULL` otherwise. -# TODO James please describe the contents of the SpatRaster object that is -# returned -#' Creates one subfolder named elev storing a raster (.tiff). If elevation is -#' sourced from geodata the elevation is downloaded at a spatial resolution of -#' 30 arc seconds (~1 km sq.). If elevation data is from mapzen then the -#' product will be a mosaic. Specifically, Mapzen’s product is unique as it -#' combines several sources of digital elevation models, including SRTM, the -#' ArcticDEM (covering all areas north of 60°), EUDEM (digital elevation model -#' over Europe; for review, see Mouratidis & Ampatzidis, 2019), and others into -#' a single product. The resolution of this product was set to 7, corresponding -#' to 611.5 m ground resolution at 60° latitude 864.8 m at 45° and 1223 m at 0°. +#' successfully, and returns `NULL` otherwise. If the elevation data is sourced +#' from geodata the SpatRaster is downloaded at a spatial resolution of 30 arc +#' seconds (~1 km sq.). If elevation data is from mapzen then the +#' SpatRaster will be a mosaic. Specifically, Mapzen’s SpatRaster is unique as +#' it combines several sources of digital elevation models, including SRTM, the +#' ArcticDEM (covering all areas north of 60°), EUDEM (digital elevation +#' model over Europe; for review, see Mouratidis & Ampatzidis, 2019), and others +#' into a single product. The resolution of this SpatRaster was set to 7, +#' corresponding to 611.5 m ground resolution at 60° latitude 864.8 m at +#' 45° and 1223 m at 0°. #' #' @author James L. Tsakalos #' @seealso A more convenient function for other climate and elevation data @@ -120,11 +118,12 @@ #' to make point objects. #' @references{ Hijmans, R.J., Barbosa, M., Ghosh, A., & Mandel, A. (2023). #' geodata: Download Geographic Data. R package version 0.5-8. -#' https://CRAN.R-project.org/package=geodata +#' \url{https://CRAN.R-project.org/package=geodata} #' #' Hollister, J. (2022). elevatr: Access Elevation Data from Various #' APIs. R package version 1.0.0. \doi{10.5281/zenodo.5809645} -#' https://CRAN.R-project.org/package=elevatr +#' \url{https://CRAN.R-project.org/package=elevatr} +#' #' #' Mouratidis, A., & Ampatzidis, D. (2019). European Digital Elevation Model #' Validation against Extensive Global Navigation Satellite Systems Data and diff --git a/R/plot_c.R b/R/plot_c.R index ba11c68..597938c 100644 --- a/R/plot_c.R +++ b/R/plot_c.R @@ -46,11 +46,12 @@ #' @param l_tcols List. Line position of the table columns. Must be length 5 #' corresponding to the position (left to right) for each column. #' -#' @return Returns a base R family of plot. This function uses the -#' \pkg{dismo} package to calculate isothermality (ISO), -#' temperature seasonality (TS) and precipitation seasonality (PS). It also uses -#' the \pkg{macroBiome} package to calculate mean annual biotemperature (BioT) -#' and the potential evapotranspiration ratio (PET). +#' @returns +#' Returns a base R family of plot. This function uses the \pkg{dismo} package +#' to calculate isothermality (ISO), temperature seasonality (TS) and +#' precipitation seasonality (PS). It also uses the \pkg{macroBiome} package to +#' calculate mean annual biotemperature (BioT) and the potential +#' evapotranspiration ratio (PET). #' #' @author James L. Tsakalos #' @seealso Download climate data: [`ce_download()`] @@ -58,7 +59,7 @@ #' Fernández-Avilés G. (2023). climaemet: Climate AEMET Tools. #' Comprehensive R Archive Network. \doi{10.5281/zenodo.5205573} #' -#' von Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav +#' Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav #' Fischer Verlag, Jena. #' #' } diff --git a/R/plot_h.R b/R/plot_h.R index cbc89aa..c94d454 100644 --- a/R/plot_h.R +++ b/R/plot_h.R @@ -9,7 +9,8 @@ #' @param col,pch,\dots Arguments to control point styling in #' `HoldridgePoints()`. #' -#' @return Returns a base R family of plot. This function uses the +#' @returns +#' Returns a base R family of plot. This function uses the #' \pkg{macroBiome} and \pkg{Ternary} packages to create a Holdridge simplex #' plot. #' diff --git a/R/plot_wl.R b/R/plot_wl.R index b137b9b..1aab33a 100644 --- a/R/plot_wl.R +++ b/R/plot_wl.R @@ -9,9 +9,9 @@ #' @param \dots Arguments to control styling in #' `ggclimat_walter_lieth()`. #' -#' @return Returns a base R family of plot. This function uses the -#' \pkg{climaemet} package to create the Walter and Lieth (1960) climatic -#' diagram. +#' @returns +#' Returns a base R family of plot. This function uses the \pkg{climaemet} +#' package to create the Walter and Lieth (1960) climatic diagram. #' #' @author James L. Tsakalos #' @seealso Download climate data: [`ce_download()`] @@ -19,7 +19,7 @@ #' Fernández-Avilés G. (2023). climaemet: Climate AEMET Tools. #' Comprehensive R Archive Network. \doi{10.5281/zenodo.5205573} #' -#' von Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav +#' Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav #' Fischer Verlag, Jena. #' #' } diff --git a/man/elev.Rd b/man/elev.Rd index 15d07be..e8330ec 100644 --- a/man/elev.Rd +++ b/man/elev.Rd @@ -25,16 +25,16 @@ downloading from Mapzen.} \value{ \code{elev()} is called for its side-effects. It invisibly returns a "SpatRaster" object if files were downloaded -successfully, and returns \code{NULL} otherwise. -Creates one subfolder named elev storing a raster (.tiff). If elevation is -sourced from geodata the elevation is downloaded at a spatial resolution of -30 arc seconds (~1 km sq.). If elevation data is from mapzen then the -product will be a mosaic. Specifically, Mapzen’s product is unique as it -combines several sources of digital elevation models, including SRTM, the -ArcticDEM (covering all areas north of 60°), EUDEM (digital elevation model -over Europe; for review, see Mouratidis & Ampatzidis, 2019), and others into -a single product. The resolution of this product was set to 7, corresponding -to 611.5 m ground resolution at 60° latitude 864.8 m at 45° and 1223 m at 0°. +successfully, and returns \code{NULL} otherwise. If the elevation data is sourced +from geodata the SpatRaster is downloaded at a spatial resolution of 30 arc +seconds (~1 km sq.). If elevation data is from mapzen then the +SpatRaster will be a mosaic. Specifically, Mapzen’s SpatRaster is unique as +it combines several sources of digital elevation models, including SRTM, the +ArcticDEM (covering all areas north of 60°), EUDEM (digital elevation +model over Europe; for review, see Mouratidis & Ampatzidis, 2019), and others +into a single product. The resolution of this SpatRaster was set to 7, +corresponding to 611.5 m ground resolution at 60° latitude 864.8 m at +45° and 1223 m at 0°. } \description{ \code{elev()} downloads elevation data the Shuttle Radar Topography Mission @@ -73,11 +73,11 @@ sf::st_crs(location) = "epsg:4326" \references{ { Hijmans, R.J., Barbosa, M., Ghosh, A., & Mandel, A. (2023). geodata: Download Geographic Data. R package version 0.5-8. -https://CRAN.R-project.org/package=geodata +\url{https://CRAN.R-project.org/package=geodata} Hollister, J. (2022). elevatr: Access Elevation Data from Various APIs. R package version 1.0.0. \doi{10.5281/zenodo.5809645} -https://CRAN.R-project.org/package=elevatr +\url{https://CRAN.R-project.org/package=elevatr} Mouratidis, A., & Ampatzidis, D. (2019). European Digital Elevation Model Validation against Extensive Global Navigation Satellite Systems Data and diff --git a/man/plot_c.Rd b/man/plot_c.Rd index 025a7b7..c6e5ba8 100644 --- a/man/plot_c.Rd +++ b/man/plot_c.Rd @@ -57,11 +57,11 @@ before wrapping to a new line.} corresponding to the position (left to right) for each column.} } \value{ -Returns a base R family of plot. This function uses the -\pkg{dismo} package to calculate isothermality (ISO), -temperature seasonality (TS) and precipitation seasonality (PS). It also uses -the \pkg{macroBiome} package to calculate mean annual biotemperature (BioT) -and the potential evapotranspiration ratio (PET). +Returns a base R family of plot. This function uses the \pkg{dismo} package +to calculate isothermality (ISO), temperature seasonality (TS) and +precipitation seasonality (PS). It also uses the \pkg{macroBiome} package to +calculate mean annual biotemperature (BioT) and the potential +evapotranspiration ratio (PET). } \description{ Creates a graph using the climate and elevation data which has @@ -101,7 +101,7 @@ par(opar) Fernández-Avilés G. (2023). climaemet: Climate AEMET Tools. Comprehensive R Archive Network. \doi{10.5281/zenodo.5205573} -von Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav +Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav Fischer Verlag, Jena. } diff --git a/man/plot_wl.Rd b/man/plot_wl.Rd index 343d19c..22747a4 100644 --- a/man/plot_wl.Rd +++ b/man/plot_wl.Rd @@ -18,9 +18,8 @@ data sets. Structured by \code{ce_extract()}.} \code{ggclimat_walter_lieth()}.} } \value{ -Returns a base R family of plot. This function uses the -\pkg{climaemet} package to create the Walter and Lieth (1960) climatic -diagram. +Returns a base R family of plot. This function uses the \pkg{climaemet} +package to create the Walter and Lieth (1960) climatic diagram. } \description{ Creates a graph using the climate and elevation data which has @@ -50,7 +49,7 @@ plot_wl(data = it_data, geo_id = "NEM") Fernández-Avilés G. (2023). climaemet: Climate AEMET Tools. Comprehensive R Archive Network. \doi{10.5281/zenodo.5205573} -von Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav +Walter, H.B., & Lieth, H. (1960). Klimadiagramm-Weltatlas. VEB Gustav Fischer Verlag, Jena. } From e22482f01adf5c5bd27998c94cdf51eebde3ef70 Mon Sep 17 00:00:00 2001 From: James Tsakalos Date: Mon, 17 Jul 2023 15:43:57 +0200 Subject: [PATCH 61/61] adding progress to suggests --- DESCRIPTION | 1 + 1 file changed, 1 insertion(+) diff --git a/DESCRIPTION b/DESCRIPTION index 732396c..2fddc42 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -54,6 +54,7 @@ Suggests: covr, fs, knitr, + progress, raster, rmarkdown, testthat (>= 3.0.0),