% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/locationCreate.r
\name{.locationCreate,character-method}
\alias{.locationCreate,character-method}
\alias{.locationCreate}
\alias{.locationCreate,SpatRaster-method}
\alias{.locationCreate,SpatVector-method}
\alias{.locationCreate,sf-method}
\title{Connect to "GRASS"}
\usage{
\S4method{.locationCreate}{character}(x, location = NULL, overwrite = FALSE, warn = TRUE)

\S4method{.locationCreate}{SpatRaster}(x, location = NULL, overwrite = FALSE, warn = TRUE)

\S4method{.locationCreate}{SpatVector}(x, location = NULL, overwrite = FALSE, warn = TRUE)

\S4method{.locationCreate}{sf}(x, location = NULL, overwrite = FALSE, warn = TRUE)
}
\arguments{
\item{x}{Any object from which a coordinate reference system (CRS) can be acquired. Ergo, any of:
\itemize{
\item A \code{SpatRaster}, \code{SpatVector}, \code{SpatExtent}, \code{stars}, or \code{sf} object
\item A \code{crs} object (i.e., from \code{\link[sf:st_crs]{sf::st_crs()}}).
\item A CRS (coordinate reference system) WKT string. Some PROJ4 strings \emph{might} work, too.
}}

\item{location}{Character or \code{NULL} (default): Name of the location.}

\item{overwrite}{Logical: If \code{FALSE} (default), and a \strong{GRASS} "coordinate reference frame" with the given name has already been created, then the function will fail. If \code{TRUE}, then the existing \strong{GRASS} "coordinate reference frame" of the same name will be overwritten. \emph{NOTE}: This will \strong{not} remove any \strong{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.}

\item{warn}{Logical: If \code{TRUE} (default) and \code{overwrite} is \code{TRUE}, then display a warning.}
}
\value{
A \link{GLocation} object (invisibly).
}
\description{
This function initializes a \strong{GRASS} "project" (previously known in \strong{GRASS} as a "location"; see \code{vignette("projects_mapsets", package = "fasterRaster")}). You need to run this function (often just once) before you use most functions in \strong{fasterRaster}. This function is of use to developers, not most users.
}
\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}
