% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/locationRestore.r
\name{.locationRestore,character-method}
\alias{.locationRestore,character-method}
\alias{.locationRestore}
\alias{.locationRestore,integer-method}
\alias{.locationRestore,numeric-method}
\alias{.locationRestore,GSpatial-method}
\title{Revert to a previously-created "GRASS" "location"}
\usage{
\S4method{.locationRestore}{character}(x)

\S4method{.locationRestore}{integer}(x)

\S4method{.locationRestore}{numeric}(x)

\S4method{.locationRestore}{GSpatial}(x)
}
\arguments{
\item{x}{Either:
\itemize{
\item A character: Name of the "location" in \strong{GRASS}.
\item An integer: Index of the "location" in \code{.fasterRaster$locations}.
\item A \code{GSpatial} object (usually a \code{GRaster} or \code{GVector}).
}

Any of these can be found using \code{.locationFind()}.}
}
\value{
An object of class \code{GLocation} (invisibly) if successful. An error will likely result if not.
}
\description{
This function resets the connection to a previously-created \strong{GRASS} "location". The session must have been already created using \code{\link[=fast]{fast()}} in the current \strong{R} session. This function is typically only of use to developers.
}
\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)

}

}
}
\keyword{internal}
