Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract() aborts when source raster has been deleted #1268

Closed
dfriend21 opened this issue Sep 5, 2023 · 3 comments
Closed

extract() aborts when source raster has been deleted #1268

dfriend21 opened this issue Sep 5, 2023 · 3 comments

Comments

@dfriend21
Copy link
Contributor

dfriend21 commented Sep 5, 2023

When the file a SpatRaster points to is deleted and that SpatRaster is plotted, an error is thrown, as expected. However, if you try to extract points from the SpatRaster, the session aborts rather than throwing an error.

library(terra)
#> terra 1.7.45

r <- rast(vals = runif(100), nrow = 10, ncol = 10, ext = c(0,10,0,10))
pts <- as.points(r)

tf <- tempfile(fileext = ".tif")
writeRaster(r, tf)

r2 <- rast(tf)
unlink(tf)

plot(r2) # throws an error
extract(r2, pts) # aborts
@rhijmans
Copy link
Member

rhijmans commented Sep 5, 2023

Thank you very much for reporting that. I now get:

plot(r2)
#Error: [readStart] file does not exist
extract(r2, pts)
#Error: [extract] file does not exist

@rhijmans
Copy link
Member

rhijmans commented Sep 5, 2023

I have expanded the error message, and I now see:

plot(r2) 
#Error: [readStart] file does not exist: C:/tmpdir/RtmpAnLJwr/file517c4f396e06.tif
extract(r2, pts) 
#Error: [extract] file does not exist: C:/tmpdir/RtmpAnLJwr/file517c4f396e06.tif

@dfriend21
Copy link
Contributor Author

Great, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants