You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running terra::viewshed() I am receiving the error: Error : [viewshed] source and target filename cannot be the same. However, I am only specifying a target filename. When wrapping terra::viewshed in try() an output is written to file and my processing continues. Without the try() the output is still generated but processing stops.
Is this an erroneous error? Some code reproducing the error:
## libraries
library(terra)
library(sf)
## version info
# R version 4.2.3 (2023-03-15 ucrt)
# terra_1.7-18
## make a raster and fill with random values
ras <- rast(nrows = 100, ncols = 100, xmin = 0, xmax = 100, ymin = 0, ymax = 100, crs = "epsg:5070")
set.seed(0)
values(ras) <- runif(ncell(ras))
# make a point (just for plotting purposes)
xy <- st_point(c(50,50))
v <- vect(xy)
crs(v) <- "epsg:5070"
# plot random raster and point
plot(ras)
points(v)
# define directory where the viewshed will be saved
of <- paste0(main_dir, "terra_test\\viewsheds\\rewritten_vs_test.tif")
# run viewshed
try(viewshed(x = ras, loc = c(50,50), observer = 1.7, target = 0, curvcoef = 0.85714, output = "yes/no", filename = of, overwrite = TRUE))
# read output back in as a rast and plot
vs_ras <- rast(of)
plot(vs_ras)
points(v)
The resulting viewshed, despite the error, seems reasonable (and I have generated many using real, less easily reproducible data that look reasonable as well).
The text was updated successfully, but these errors were encountered:
When running terra::viewshed() I am receiving the error: Error : [viewshed] source and target filename cannot be the same. However, I am only specifying a target filename. When wrapping terra::viewshed in try() an output is written to file and my processing continues. Without the try() the output is still generated but processing stops.
Is this an erroneous error? Some code reproducing the error:
The resulting viewshed, despite the error, seems reasonable (and I have generated many using real, less easily reproducible data that look reasonable as well).
The text was updated successfully, but these errors were encountered: