terra icon indicating copy to clipboard operation
terra copied to clipboard

Inconsistency between raster and polygon area

Open AMBarbosa opened this issue 1 year ago • 0 comments

Hi,

I expected these expanse() outputs to be the same, but they vary slightly:

r <- rast(system.file("ex/elev.tif", package="terra"))
plot(r)
r_cellsize <- cellSize(r, mask = TRUE)
plot(r_cellsize)
r_pol <- as.polygons(r*0)
plot(r_pol, add = TRUE)

expanse(r)  # 2563610102
sum(data.frame(r_cellsize))  # same
expanse(r_pol)  # 2563614794

AMBarbosa avatar Feb 26 '24 14:02 AMBarbosa