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

Sieve filter breaks if .tif is too big #1061

Closed
leoleoleoleoleoleoleoleoleoleoleoleo opened this issue Mar 9, 2023 · 4 comments
Closed

Sieve filter breaks if .tif is too big #1061

leoleoleoleoleoleoleoleoleoleoleoleo opened this issue Mar 9, 2023 · 4 comments

Comments

@leoleoleoleoleoleoleoleoleoleoleoleo

Hi,

Using the sieve function, it appears that it works well with virtual rasters with a small subset (5000x5000 is fine). However, when I increase the size of the raster (6000x6000), it starts giving me this error : Error: [sieve] cannot open this file as a SpatRaster: /tmp/RtmpsUhNEw/spat_tACuk024N9dV6vz_24355.tif In addition: Warning message: /tmp/RtmpsUhNEw/spat_tACuk024N9dV6vz_24355.tif' not recognized as a supported file format. (GDAL error 4)

Any idea why ? May be related to the fact I'm using virtual rasters, but I'm not sure how to test this.

Thank you in advance

@rhijmans
Copy link
Member

rhijmans commented Mar 9, 2023

Thank you for reporting this. The function failed when writing to disk, either by providing a filename argument, or, as in your case, when a large dataset is written to a temp file. This now works:

library(terra)
r <- rast(nrows=18, ncols=18, xmin=0, vals=0, crs="local")
r[2, 5] <- 1
r[5:8, 2:3] <- 2
r[7:12, 10:15] <- 3
r[15:16, 15:18] <- 4
freq(r, bylayer=FALSE)

x <- sieve(r, 8, filename="test.tif", overwrite=TRUE)

@leoleoleoleoleoleoleoleoleoleoleoleo

Thank you for your answer ! I'm not sure I understand, because the code you provided did not work on my machine : are you saying your example (and my problem) will work in the next release ?

@rhijmans
Copy link
Member

rhijmans commented Mar 10, 2023

I have fixed this with d4d5c44. And I showed that this now works in the development version. You can install the development version if you want to try it (see the instructions )

@leoleoleoleoleoleoleoleoleoleoleoleo

Right, thank you so much !

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