diff --git a/DESCRIPTION b/DESCRIPTION index 2e681a3..38fd32c 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: elevatr Title: Access Elevation Data from Various APIs -Version: 0.99.0 +Version: 1.0.0.9999 Authors@R: c(person("Jeffrey", "Hollister", email = "hollister.jeff@epa.gov", role = c("aut", "cre"), comment = c(ORCID = "0000-0002-9254-9740")), person("Tarak", "Shah", role = "ctb"), diff --git a/NEWS.md b/NEWS.md index 0f122a7..e8014d0 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +elevatr 0.99.0 (2024-0x-xx) +============= +# API Changes +- add argument for specifying temp directory for download files. Allows users to specify a specific location. (Thanks, @andrew-caudillo: https://github.com/jhollist/elevatr/issues/95) + + elevatr 0.99.0 (2023-09-11) ============= diff --git a/R/get_elev_raster.R b/R/get_elev_raster.R index 6161368..b40097b 100644 --- a/R/get_elev_raster.R +++ b/R/get_elev_raster.R @@ -85,7 +85,7 @@ get_elev_raster <- function(locations, z, prj = NULL, src = c("aws", "gl3", "gl1", "alos", "srtm15plus"), expand = NULL, clip = c("tile", "bbox", "locations"), verbose = TRUE, neg_to_na = FALSE, - override_size_check = FALSE, ...){ + override_size_check = FALSE, tmp_dir = tempdir(), ...){ # First Check for internet if(!curl::has_internet()) { message("Please connect to the internet and try again.") @@ -192,7 +192,7 @@ get_elev_raster <- function(locations, z, prj = NULL, get_aws_terrain <- function(locations, z, prj, expand=NULL, ncpu = future::availableCores() - 1, - serial = NULL, ...){ + serial = NULL, tmp_dir = tempdir(), ...){ # Expand (if needed) and re-project bbx to dd bbx <- proj_expand(locations,prj,expand) @@ -236,7 +236,8 @@ get_aws_terrain <- function(locations, z, prj, expand=NULL, dem_list <- purrr::map(urls, function(x){ p() - tmpfile <- tempfile(fileext = ".tif") + tmpfile <- tempfile(tmpdir = tmp_dir, + fileext = ".tif") resp <- httr::GET(x, httr::user_agent("elevatr R package (https://github.com/jhollist/elevatr)"), httr::write_disk(tmpfile,overwrite=TRUE), ...) @@ -254,7 +255,7 @@ get_aws_terrain <- function(locations, z, prj, expand=NULL, dem_list <- furrr::future_map(urls, function(x){ p() - tmpfile <- tempfile(fileext = ".tif") + tmpfile <- tempfile(tempdir = tmp_dir, fileext = ".tif") resp <- httr::GET(x, httr::user_agent("elevatr R package (https://github.com/jhollist/elevatr)"), httr::write_disk(tmpfile,overwrite=TRUE), ...) @@ -297,11 +298,12 @@ get_aws_terrain <- function(locations, z, prj, expand=NULL, #' @export #' @keywords internal -merge_rasters <- function(raster_list, target_prj, method = "bilinear", returnRaster = TRUE){ +merge_rasters <- function(raster_list, target_prj, method = "bilinear", + returnRaster = TRUE, tmp_dir = tempdir()){ message(paste("Mosaicing & Projecting")) - destfile <- tempfile(fileext = ".tif") + destfile <- tempfile(tempdir = temp_dir, fileext = ".tif") files <- unlist(raster_list) if(is.null(target_prj)){ @@ -316,7 +318,7 @@ merge_rasters <- function(raster_list, target_prj, method = "bilinear", returnR ) # Using two steps now as gdal with one step introduced NA's along seams # Slower but more accurate! - destfile2 <- tempfile(fileext = ".tif") + destfile2 <- tempfile(tempdir = temp_dir, fileext = ".tif") sf::gdal_utils(util = "warp", source = destfile, destination = destfile2, @@ -352,14 +354,15 @@ merge_rasters <- function(raster_list, target_prj, method = "bilinear", returnR #' vector. #' @export #' @keywords internal -get_opentopo <- function(locations, src, prj, expand=NULL, ...){ +get_opentopo <- function(locations, src, prj, expand=NULL, tmp_dir = tempdir(), + ...){ api_key <- get_opentopo_key() # Expand (if needed) and re-project bbx to ll_geo bbx <- proj_expand(locations,prj,expand) - tmpfile <- tempfile() + tmpfile <- tempfile(tempdir = temp_dir) base_url <- "https://portal.opentopography.org/API/globaldem?demtype=" data_set <- switch(src, gl3 = "SRTMGL3", diff --git a/cran_comments.md b/cran_comments.md index aef1465..d4f609d 100644 --- a/cran_comments.md +++ b/cran_comments.md @@ -2,6 +2,7 @@ - Modified startup message to note switch to sf and terra, but keeping RasterLayer as output for now.. - NOTEs in CRAN check results have been addressed. +- Resubmission for issues with package names and object types in DESCRIPTION ## Test Environments