Skip to content

More efficient raster extraction

1 message · GD

GD
#
Hi,

In the past I had a similar issue (86000 polygons), and found a 
reasonably efficient approach was to:

1) Take my polygons, and burn a unique ID value for each into a new 
raster, with the same dimensions/cellsize as the target raster (300m 
pixels in your case). I did this outside of R, using gdal_rasterize.

2) Use 'crosstab' in the raster package in R to get the values of the 
target raster associated with each polygon ID.

Cheers,
Gareth.