I'm using the new velox extract function to speed up raster extraction by shapefiles.
The old raster package's extract function by default returned a list of cell values, for example when you use the below format:
val.list <- raster::extract(raster, shapefile)
The new velox package requires a fun= argument and I can't for the life of me get it to return the values:
vx.raster <- velox(raster)
vx.vals <- vx.raster$extract(shapefile, fun=??????)
I have tried:
fun=values (returns error Error during wrapup: unable to find an inherited method for function 'values' for signature 'numeric'
fun=function(x){values(x)} (same error as above)
I get fun=sum, fun=mean to work just fine. Whats up with values? Am I just missing something obvious about a numeric vector and returning a values list (which I feel is the most likely case)?
Thank you!
Simply try this snippet