This function initializes a GRASS "location". You need to run this function (often just once) before you use most functions in fasterRaster. This function is of use to developers, not most users.
Usage
# S4 method for class 'character'
.locationCreate(x, location = NULL, overwrite = FALSE, warn = TRUE)
# S4 method for class 'SpatRaster'
.locationCreate(x, location = NULL, overwrite = FALSE, warn = TRUE)
# S4 method for class 'SpatVector'
.locationCreate(x, location = NULL, overwrite = FALSE, warn = TRUE)
# S4 method for class 'sf'
.locationCreate(x, location = NULL, overwrite = FALSE, warn = TRUE)
Arguments
- x
Any object from which a coordinate reference system (CRS) can be acquired. Ergo, any of:
A
SpatRaster
,SpatVector
,SpatExtent
,stars
, orsf
objectA
crs
object (i.e., fromsf::st_crs()
).A CRS (coordinate reference system) WKT string. Some PROJ4 strings might work, too.
- location
Character or
NULL
(default): Name of the location.- overwrite
Logical: If
FALSE
(default), and a GRASS "coordinate reference frame" with the given name has already been created, then the function will fail. IfTRUE
, then the existing GRASS "coordinate reference frame" of the same name will be overwritten. NOTE: This will not remove any R objects associated with rasters or vectors in the "location", but they will no longer work because the objects they point to will be overwritten.- warn
Logical: If
TRUE
(default) andoverwrite
isTRUE
, then display a warning.
Value
A GLocation object (invisibly).
Examples
if (grassStarted()) {
# Setup
library(terra)
# Example data
madElev <- fastData("madElev")
madChelsa <- fastData("madChelsa")
madChelsa1 <- madChelsa[[1]]
# Convert SpatRasters to GRasters.
# Each raster has a different CRS so will be put into a different location.
elev <- fast(madElev)
chelsa1 <- fast(madChelsa1)
# Name of the currently active location
.location()
.location(elev)
.location(chelsa1)
# All available GRASS locations
.locations()
# Find location of an object among all active locations
.locationFind(elev)
.locationFind(chelsa1)
.locationFind(chelsa1, return = "index")
.locationFind(chelsa1, return = "crs")
# Switch between locations
.locationRestore(elev)
.locationRestore(chelsa1)
loc <- .location(elev)
.locationRestore(loc)
# We could use .locationDelete(elev) to delete
# the location where "elev" is stored.
# Mapsets are always "PERMANENT" in fasterRaster
.mapset()
.mapset(elev)
.mapset(chelsa1)
}