isciences / exactextractr

R package for fast and accurate raster zonal statistics
https://isciences.gitlab.io/exactextractr/
272 stars 26 forks source link

Error: [crop] incorrect number of values (too many) for writing #97

Closed mjdcurtis closed 1 year ago

mjdcurtis commented 1 year ago

Tried to extract a big ascii raster with max_cells_in_memory = 200000000L and got this message:

Error: [crop] incorrect number of values (too many) for writing

(If I use a smaller value of max_cells_in_memory, I get:

Cannot preload entire working area of 174974720 cells with max_cells_in_memory = 50000000. Raster values will be read for each feature individually, which is very slow.)

dbaston commented 1 year ago

This error is coming from terra. Apparently it is trying to write the cropped raster to disk, which even if successful would defeat the purpose of preloading it.

Can you try increasing the memory available to terra to see if this goes away? https://rspatial.github.io/terra/reference/terraOptions.html

mjdcurtis commented 1 year ago

Just tried increasing terraOptions's memfrac and memmax, no luck.

Perhaps I do not have enough RAM / it's trying to write to swap.

I can just work around it though by cropping my sf object before extracting the raster.

Thanks!