Open brownag opened 4 years ago
I like it. Anything that makes the report faster is a good thing. I would like to do some profiling on the sampling code to see if that or raster::extract
is the bottle-neck. I'm not sure, but perhaps we can use this kind of sampling to assist with reasonable adjustments to an effective sampling size (e.g. #26).
This is a note to consider use of
exactextractr
package for faster raster extraction. I know we are expectingterra
to be available in the near future, not sure how the performance of these will compare. My preliminary tests show extraction withterra
operating at similar speeds toraster
, maybe a little faster.It seems
exactextractr::exact_extract
is orders of magnitude faster thanraster::extract
. It is available on CRAN and relies on GEOS.Here is a small example showing processing of a PRISM raster. Though, I think the performance enhancement really shows when using more detailed rasters.
Extraction of a small (10m) buffer around several point locations:
Ordinary point extraction faster with raster/terra
But, you can create tiny polygons buffered around points and extract then nearly as fast with exactextractr. Calculating the weighted mean composition is an easy extension
in comparable time to simple point extraction, extract 10m radius:
Auto-weighted mean by contributing proportion ~ "point" values