From c44e900e04089c7229264bcad0145df7a3485d6b Mon Sep 17 00:00:00 2001 From: CeresBarros Date: Fri, 9 Feb 2024 17:20:03 -0800 Subject: [PATCH] break link to input xyz before changing it internally --- R/dbGetRaster.R | 2 +- R/downscale.R | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/R/dbGetRaster.R b/R/dbGetRaster.R index fb910d6b..066dda0e 100644 --- a/R/dbGetRaster.R +++ b/R/dbGetRaster.R @@ -174,7 +174,7 @@ pgGetTerra <- function(conn, name, tile, rast = "rast", bands = 37:73, #' @return integer. A bounding box (e.g. `c(51, 50, -121, -122)`) #' @export get_bb <- function(in_xyz) { - .checkXYZ(in_xyz) + .checkXYZ(copy(in_xyz)) thebb <- c(max(in_xyz[, "lat"]), min(in_xyz[, "lat"]), max(in_xyz[, "lon"]), min(in_xyz[, "lon"])) if (any(is.na(thebb))) { diff --git a/R/downscale.R b/R/downscale.R index ce324402..13ff13d3 100644 --- a/R/downscale.R +++ b/R/downscale.R @@ -94,7 +94,7 @@ climr_downscale <- function(xyz, which_normal = c("auto", list_normal()), histor gcm_hist_years, max_run, vars) expectedCols <- c("lon", "lat", "elev", "id") - xyz <- .checkXYZ(xyz, expectedCols) + xyz <- .checkXYZ(copy(xyz), expectedCols) dbCon <- data_connect() thebb <- get_bb(xyz) ## get bounding box based on input points @@ -310,7 +310,7 @@ downscale <- function(xyz, normal, gcm = NULL, historic = NULL, gcm_ts = NULL, g historic_ts, return_normal, vars) expectedCols <- c("lon", "lat", "elev", "id") - xyz <- .checkXYZ(xyz, expectedCols) + xyz <- .checkXYZ(copy(xyz), expectedCols) if (isTRUE(nthread > 1L)) { if (!requireNamespace("parallel")) {