openSTARS (version 1.0.0)

setup_grass_environment: Setup 'GRASS' environment.

Description

This function sets the 'GRASS' mapset to PERMANENT and sets its projection and extension.

Usage

setup_grass_environment(dem, sites = NULL, epsg = NULL, proj4 = NULL)

Arguments

dem

character; path to DEM.

sites

character string or object; path to sites vector file (shape) or sp data object.

epsg

number; EPSG code for the spatial reference to be used

proj4

(optional) proj4 string; character string of projection arguments

Value

Nothing, the 'GRASS' mapset is set to PERMANENT, projection is set to the one of the sites shape, to the proj4 string or to the epsg code provided, the extent of the region is set to the one of bounding box of the dem.

Examples

Run this code
# NOT RUN {
# Initiate GRASS session
if(.Platform$OS.type == "windows"){
  gisbase = "c:/Program Files/GRASS GIS 7.2.0"
  } else {
  gisbase = "/usr/lib/grass72/"
  }
initGRASS(gisBase = gisbase,
    home = tempdir(),
    override = TRUE)

# Load files into GRASS
dem_path <- system.file("extdata", "nc", "elev_ned_30m.tif", package = "openSTARS")
sites_path <- system.file("extdata", "nc", "sites_nc.shp", package = "openSTARS")
setup_grass_environment(dem = dem_path, sites = sites_path)
gmeta()
# }

Run the code above in your browser using DataLab