location: GRASS "location" of an object or the active session

.location,GLocation-methodR Documentation

GRASS "location" of an object or the active session

Description

GRASS "projects" or "locations" are sets of one or more rasters and/or vectors with the same coordinate reference systems, and may or may not represent the same actual location on Earth. GRASS "mapsets" are like sub-folders of locations, and are collections of rasters and/or vectors typically related to the same general project. Typical users will not need to make changes to the default location (called "location") or mapset (called "PERMANENT"). See vignette("projects_mapsets", package = "fasterRaster").

This function deletes a GRASS "project"/"location", rasters, and vectors therein. This function should be used cautiously and is mainly of use to developers. See vignette("projects_mapsets", package = "fasterRaster").

Usage

## S4 method for signature 'GLocation'
.location(x)

## S4 method for signature 'missing'
.location(x)

.locationDelete(location, mapset = NULL, workDir = NULL)

Arguments

x

Either:

  • Missing: Reports location of currently active project/location.

  • A GLocation object or an object that contains the GLocation class (i.e., a GSpatial object: a GRaster or GVector).

location

Character: Name of the GRASS "location".

mapset

Character or NULL (default): Name of the mapset to delete. If NULL, then all mapsets in the given "location" will be deleted.

workDir

Character: Either NULL (default) or a character string of the directory in which the location to be removed resides. If NULL, then the working directory will be obtained from faster("workDir").

Value

A character string.

If successful, TRUE (invisibly). If not, then FALSE (also invisibly), plus a warning.

See Also

.mapset()

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
if (FALSE) {
   
   .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)

   # Delete the location where "elev" is stored.
   if (FALSE) .locationDelete(elev) # dangerous!

   # Mapsets are always "PERMANENT" in fasterRaster
   .mapset()
   .mapset(elev)
   .mapset(chelsa1)

}

}
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
if (FALSE) {
   
   .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)

   # Delete the location where "elev" is stored.
   if (FALSE) .locationDelete(elev) # dangerous!

   # Mapsets are always "PERMANENT" in fasterRaster
   .mapset()
   .mapset(elev)
   .mapset(chelsa1)

}

}

adamlilith/fasterRaster documentation built on Oct. 26, 2024, 4:06 p.m.