fasterRaster functions attempt to delete rasters and vectors in the GRASS cache, but not all intermediate files can be removed. This function can be used to clear the cache of extraneous rasters and vectors.
Calling this function inside another function's environment and defining x as "*" can be very dangerous, as it will detect objects outside of that environment, and thus delete any rasters/vectors outside that environment. Here is a guide:
To delete files associated with a single
GRasterorGVector, usemow(GRaster_to_unlink)ormow(GVector_to_unlink).To delete files associated with more than one
GRasters and/orGVectors, provide them as a list. For example, usemow(list(GRaster_to_unlink, GVector_to_unlink)).To remove all rasters, all vectors, or all rasters and vectors in the GRASS cache that are not linked to a
GRasterorGVector, usemow("*").To remove all rasters or all vectors in the GRASS cache, use
mow("*", type = "rasters")ormow("*", type = "vectors").To remove all rasters or all vectors in the GRASS cache except for certain ones, use
mow("*", keep = list(GRaster_to_keep, GVector_to_keep)). You can combine this with thekeepargument to retain specific rasters or vectors. For example, you can usemow("*", type = "rasters", keep = list(GRaster_to_keep)).
Arguments
- x
Any of:
"unlinked"(default): Delete GRASS rasters and/or vectors that are unlinked toGRasters orGVectors in the environment in which the function was called, or the environment named inpos.A
GRasterorGVector: Delete the GRASS raster or vector pointed to by this object.A
listofGRasters and/orGVectors: Delete the GRASS raster(s) and/or vector(s) pointed to by these objects."*": Delete all GRASS rasters and/or vectors pointed to by objects in the environment named inpos. Only objects inkeepwill not be deleted.
- pos
Either
NULL(default), or an environment. This is used only ifxis"unlinked"or"*". In that case, ifposisNULL, the environment in which this function was called will be searched forGRasters andGVectors for removal of their associated GRASS rasters and vectors. Otherwise, the named environment will be searched.- type
Either
NULLor a character vector. This is used only ifxis"unlinked"or"*". IfNULL, all rasters and vectors in the GRASS cache are candidates for deletion. Otherwise, this can be either"rasters","vectors", or both.- keep
Either
NULL(default) or alist()ofGRasters and/orGVectors that you want to retain. This is used only ifxis"unlinked"or"*". The rasters and vectors in GRASS pointed to by these objects will not be deleted.- verbose
Logical: If
TRUE(default), report progress.- ask
Logical: If
TRUE(default), prompt for reassurance. This is used only ifxis"unlinked"or"*".
Examples
if (grassStarted()) {
# Setup
madElev <- fastData("madElev")
elev <- fast(madElev)
mow(elev, ask = TRUE) # delete GRASS raster attached to `elev`
}
