# NOT RUN {
# load data
data(sim_pu_polygons, sim_features)
# }
# NOT RUN {
# we will investigate several ways for extracting values from a raster
# using polygons. Specifically, for each band in the raster,
# for each polygon in the vector layer, calculate the average
# of the cells that are inside the polygon.
# perform the extraction using the standard raster::extract function
system.time({result <- fast_extract(sim_features, sim_pu_polygons)})
# perform extract using the fast_extract function augmented using the
# "velox" package
system.time({result <- fast_extract(sim_features, sim_pu_polygons,
velox = TRUE)})
# perform extract using the fast_extract function with "velox" package
# and using two threads for processing. Note that this might be slower
# due to overheads but should yield faster processing times on larger
# spatial data sets
set_number_of_threads(2)
system.time({result <- fast_extract(sim_features, sim_pu_polygons,
velox = TRUE)})
set_number_of_threads(1)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab