terra
terra copied to clipboard
Does rasterize(cover=TRUE) fail silently when ncell too big?
I am attempting to rasterize polygons to a ~1km global grid using cover=TRUE to get a measure of uncertainty for rasterising the polygons (some input data are small and detailed, others not - but I am using touches=TRUE so both transfer to the resulting raster).
I think I was being naive and optimistic, but I thought that terra would be able to do this at ~1km resolution, just really slowly. It works at ~10km resolution with the code below, but seems to silently fail at ~1km. Is this deliberate as a result of the number of cells being too big?
library(terra)
#1.7.39
r = rast(res=1/12)
v = vect(spatSample(ext(r),size=1000,lonlat=FALSE))
v = crop(voronoi(v),rast())
v = sample(v,size=100)
rr = rasterize(v,r,cover=TRUE)
rr
r = rast(res=1/120)
rr = rasterize(v,r,cover=TRUE)
rr
Thanks. That is not intentional.
( still valid on 1.7-71 )
right now I'm :
- rasterizing the polygon's variable at a finer resolution
- extracting a matrix containing the centers of the cells
- rasterizing them at a coarser resolution counting with
fun = length
Are there any other viable alternatives as workaround?