Does anyone know an equivalent package for the
velox package for fast zonal statistics in R? This package was by far the best performing tool when working with large raster objects but has been recently removed from CRAN...
I have moved to using the
exact_extract function in the
exactextractr package. One nice thing is that it returns all cell intersections with the fractional proportion of each cells intersection. You could use the proportion of intersection column as weights or to filter out small intersections.
Also, there are numerous statistics available, including some weighted ones, that are part of the C++ code, so very fast. The package takes
sf class polygons and
raster class raster data.
You can use the
#random sampling points: pts <- readOGR( dsn = ".", layer = "random_points", encoding = "utf8") pts$id <- as.numeric(pts$id) pts <- as.data.frame(pts) library(mmand) library(raster) r1 = raster("G:/romain/imperviousness_project/SWI.tif") #Let's rasterize the points based on their x y coordinates: z <- rasterize(pts[,2:3], r1, field = pts$id) #I want to get statistic from a zone of 3*3 pixels around my point (in my example 1 pixel = 5 meters so the total area is 15m2): kern <- shapeKernel(c(3,3), type="box") z[,] <- dilate(as.matrix(z), kern) plot(z) zonal(r1, z, fun = "mean")