From 018d9f90b1b52886fc03c8c1294410b3d0d01212 Mon Sep 17 00:00:00 2001 From: Jean-Romain Date: Wed, 16 Aug 2023 08:27:04 -0400 Subject: [PATCH] Fix #694 --- R/utils_raster.R | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/R/utils_raster.R b/R/utils_raster.R index 0099fc74..99da2723 100644 --- a/R/utils_raster.R +++ b/R/utils_raster.R @@ -211,7 +211,16 @@ raster_as_matrix <- function(raster, downsample = FALSE) #' @importFrom stats na.omit raster_as_dataframe <- function(raster, xy = TRUE, na.rm = TRUE) { - if (raster_is_proxy(raster)) + ondisk <- raster_is_proxy(raster) + + # Small rasters can be loaded on the fly + if (ondisk & raster_fits_in_memory(raster, n = 10)) + { + raster <- raster_in_memory(raster) + ondisk <- FALSE + } + + if (ondisk) stop("On-disk rasters not supported in 'raster_as_dataframe()'", call. = FALSE) # nocov m <- raster_as_matrix(raster)