
Making fasterRaster faster
Adam B. Smith
2025-06-19
Source:vignettes/faster_fasterRaster.Rmd
faster_fasterRaster.RmdThere are several ways to speed up fasterRaster functions. These are listed below in order of their most likely gains, with the first few being potentially the largest.
Load rasters and vectors directly from disk: Use
fast()to load rasters and vectrors directly from disk. Convertingterraorsfobjects toGRasters andGVectors can be slower. Why? Because if the object does not have a file to which theRobject points, Usefast()has to save it to disk first as a GeoTIFF or GeoPackage file, then load it intoGRASS.Save
GRasters andGVectors directly to disk: ConvertingGRasters andGVectors toSpatRasters orSpatVectorusingrast()orvect(), then saving them is much slower than just saving them. Why? Because these functions actually save the file to disk then uses the respective function from the respective package to connect to the file.Increase memory and the number of cores usable by GRASS: By default,
fasterRasteruse 2 cores and 2048 MB (2 GB) of memory forGRASSmodules that allow users to specify these values. You can set these to higher values usingfaster()and thus potentially speed up some calculations. Functions in newer versions ofGRASShave more capacity to use these options, so updatingGRASSto the latest version can help, too.Do operations on
GRasters andGVectors in the same coordinate reference system together: Every time you switch between using aGRasterorGVectorwith a different coordinate reference system (CRS),GRASShas to spend a few seconds changing to that CRS. You can save some time by doing as much work as possible with objects in one CRS, then switching to work on objects in another CRS.
~ FINIS ~