Skip to content

Commit

Permalink
see if this change breaks things.
Browse files Browse the repository at this point in the history
  • Loading branch information
jhollist committed Jan 24, 2024
1 parent 7b11c90 commit aa5c84c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion 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"),
Expand Down
6 changes: 6 additions & 0 deletions 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)
=============

Expand Down
21 changes: 12 additions & 9 deletions R/get_elev_raster.R
Expand Up @@ -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.")
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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), ...)
Expand All @@ -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), ...)
Expand Down Expand Up @@ -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)){
Expand All @@ -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,
Expand Down Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions cran_comments.md
Expand Up @@ -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

Expand Down

0 comments on commit aa5c84c

Please sign in to comment.