rspatial / terra

R package for spatial data handling https://rspatial.github.io/terra/reference/terra-package.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

gridDist - cannot overwrite existing file error

ClarePearson opened this issue · comments

Hello,

I've been trying to create a distance surface with gridDist but keep getting the error "cannot overwrite existing file". This only happens when running the function on larger rasters, I think because it can't overwrite the temp file being created in the process?

minimal example:

require(terra)

r <- rast(ext = ext(c(xmin = 0, xmax = 7e+05, ymin = 0, ymax = 1300000)), res = 25, crs = "EPSG:27700")

r[] <- 1:ncell(r)

r_test <- gridDist(r, target=100, maxiter = 100, overwrite=T)

windows 10 64-bit, terra version ‘1.7.78’, R version 4.4.0,
gdal proj geos
"3.8.4" "9.3.1" "3.12.1"

Thank you very much for reporting. I believe this has been fixed now. You can test with a smaller dataset by setting the option "todisk" to TRUE (this simulates using a large dataset).

library(terra)
r <- rast(ext = ext(c(xmin = 0, xmax = 7e+05, ymin = 0, ymax = 1300000)), res = 25000, crs = "EPSG:27700")
r[] <- 1:ncell(r)
terraOptions(todisk=T)
r_test <- gridDist(r, target=100, maxiter = 100, overwrite=T)