[R-sig-Geo] More efficient raster extraction

Gareth Davies grothered at gmail.com
Tue Sep 15 12:14:45 CEST 2015


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.


More information about the R-sig-Geo mailing list