Search code examples
rterrar-stars

Area of each cell covered by polygons


Is there a way/function to calculate the proportion of each raster cell covered by a polygon? The polygons are usually larger than single cells and the landscape I'm working on is pretty big. I'll like to do it without converting the raster into cell-polygons and st_union/st_join, but I'm not sure if it's possible.

The output I'm looking for is a raster with cell values showing the proportion of each cell covered by the polygons layer.


Solution

  • Thanks for the comments. At the end the terra::rasterize() function with the cover = T parameter applied on the polygons layer does exactly what I was looking for... and it's super fast.

    I was able to keep it all on the "raster side" and avoid the more intense processing of vectorizing the raster template and doing intersects/spatial joins.