Replies: 1 comment 6 replies
-
Is it possible to read the raster data completely back into memory? Presumably the object was originally in memory before it was saved to disk, so I would be surprised if Here is a version of the reprex for callr::r(func = function() {
library(terra)
raster <- rast(nrows = 10L, ncols = 10L)
values(raster) <- seq_len(100L)
writeRaster(raster, "output.tif", overwrite = TRUE)
NULL
})
#> NULL
library(terra)
#> terra 1.7.78
object <- rast("output.tif")
unlink("output.tif")
values(object)
#> Error: [readStart] file does not exist: /private/var/folders/4v/vh7xp8553lsbl49svl48g7p00000gp/T/RtmpxuqUGO/reprex-2fcf72a02fe6-surly-egg/output.tif Created on 2024-11-05 with reprex v2.1.1 Session infosessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.4.0 (2024-04-24)
#> os macOS 15.1
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz America/Indiana/Indianapolis
#> date 2024-11-05
#> pandoc 3.2 @ /Applications/RStudio.app/Contents/Resources/app/quarto/bin/tools/aarch64/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> callr 3.7.6 2024-03-25 [1] CRAN (R 4.4.0)
#> cli 3.6.3 2024-06-21 [1] CRAN (R 4.4.0)
#> codetools 0.2-20 2024-03-31 [1] CRAN (R 4.4.0)
#> digest 0.6.37 2024-08-19 [1] CRAN (R 4.4.1)
#> evaluate 1.0.1 2024-10-10 [1] CRAN (R 4.4.1)
#> fastmap 1.2.0 2024-05-15 [1] CRAN (R 4.4.0)
#> fs 1.6.4 2024-04-25 [1] CRAN (R 4.4.0)
#> glue 1.8.0 2024-09-30 [1] CRAN (R 4.4.0)
#> htmltools 0.5.8.1 2024-04-04 [1] CRAN (R 4.4.0)
#> knitr 1.48 2024-07-07 [1] CRAN (R 4.4.0)
#> lifecycle 1.0.4 2023-11-07 [1] CRAN (R 4.4.0)
#> processx 3.8.4 2024-03-16 [1] CRAN (R 4.4.0)
#> ps 1.8.0 2024-09-12 [1] CRAN (R 4.4.1)
#> R6 2.5.1 2021-08-19 [1] CRAN (R 4.4.0)
#> Rcpp 1.0.13 2024-07-17 [1] CRAN (R 4.4.0)
#> reprex 2.1.1 2024-07-06 [1] CRAN (R 4.4.0)
#> rlang 1.1.4 2024-06-04 [1] CRAN (R 4.4.0)
#> rmarkdown 2.28 2024-08-17 [1] CRAN (R 4.4.0)
#> rstudioapi 0.16.0 2024-03-24 [1] CRAN (R 4.4.0)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.4.0)
#> terra * 1.7-78 2024-05-22 [1] CRAN (R 4.4.0)
#> withr 3.0.1 2024-07-31 [1] CRAN (R 4.4.0)
#> xfun 0.48 2024-10-03 [1] CRAN (R 4.4.1)
#> yaml 2.3.10 2024-07-26 [1] CRAN (R 4.4.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.4-arm64/Resources/library
#>
#> ────────────────────────────────────────────────────────────────────────────── |
Beta Was this translation helpful? Give feedback.
-
Help
Description
I'm not sure if this is intended behavior or not, but it appears that when using cloud storage with
targets
runningtar_read()
ortar_make()
1) downloads the target from the cloud totempdir()/_targets/scratch/
, 2) runs the read function for the target, 3) deletes the file inscratch/
. This causes proxy objects liketerra
SpatRaster
objects to be broken because they do not necessarily contain the data, just a file pointer. Would it maybe make more sense for the files inscratch/
to stick around for the lifetime of the interactive R session? This also seems to cause trouble for downstream targets though, so maybe there's a different solution.Reprex with
geotargets
:Created on 2024-11-04 with reprex v2.1.1
Simple reprex showing that the download immediately ceases to exist:
Created on 2024-11-04 with reprex v2.1.1
(You'll have to either have your own S3 bucket to try this with, or I can privately share credentials for this one if neccessary)
Beta Was this translation helpful? Give feedback.
All reactions