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
GRaster
orGVector
, usemow(GRaster_to_unlink)
ormow(GVector_to_unlink)
. To remove all rasters, all vectors, or all rasters and vectors in the GRASS cache that are not linked to aGRaster
orGVector
, usemow("*")
. To remove all rasters or all vectors in the GRASS cache, usemow("*", type = "rasters")
ormow("*", type = "vectors")
. To remove all rasters or all vectors in the GRASS cache except for certain ones, usemow("*", unlinked = FALSE, keep = list(GRaster_to_keep, GVector_to_keep))
. You can combine this with thekeep
argument to retain specific rasters or vectors. For example, you can usemow("*", unlinked = FALSE, type = "rasters", keep = list(GRaster_to_keep))
.
Arguments
- x
Any of:
"unlinked"
(default): Delete GRASS rasters and/or vectors that are unlinked toGRaster
s orGVector
s in the environment in which the function was called, or the environment named inpos
.A
GRaster
orGVector
: Delete the GRASS raster or vector pointed to by this object.A
list
ofGRaster
s and/orGVector
s: 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 inkeep
will not be deleted.
- pos
Either
NULL
(default), or an environment. This is used only ifx
is"unlinked"
or"*"
. In that case, ifpos
isNULL
, the environment in which this function was called will be searched forGRaster
s andGVector
s for removal of their associated GRASS rasters and vectors. Otherwise, the named environment will be searched.- type
Either
NULL
or a character vector. This is used only ifx
is"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()
ofGRaster
s and/orGVector
s that you want to retain. This is used only ifx
is"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 ifx
is"unlinked"
or"*"
.
Examples
if (grassStarted()) {
# Setup
madElev <- fastData("madElev")
elev <- fast(madElev)
mow(elev, ask = TRUE) # delete GRASS raster attached to `elev`
}