GRASS LOCATION metadata are read into a list in R; helper function getLocationProj returns an spproj-compliant PROJ.4 string of projection information. The helper function gmeta2grd creates a GridTopology object from the current GRASS mapset region definitions. The new use_sf() and use_sp() functions permit the user to use "sf" and "stars" classes for raster and vector objects in R; use will be extended over time.

use_sf()
use_sp()
gmeta(ignore.stderr = FALSE, g.proj_WKT=NULL)
getLocationProj(ignore.stderr = FALSE, g.proj_WKT=NULL)
gmeta2grd(ignore.stderr = FALSE)
# S3 method for gmeta
print(x, ...)
get.ignore.stderrOption()
get.stop_on_no_flags_parasOption()
get.useGDALOption()
get.pluginOption()
get.echoCmdOption()
get.useInternOption()
get.legacyExecOption()
get.defaultFlagsOption()
get.suppressEchoCmdInFuncOption()
set.ignore.stderrOption(value)
set.stop_on_no_flags_parasOption(value)
set.useGDALOption(value)
set.pluginOption(value)
set.echoCmdOption(value)
set.useInternOption(value)
set.legacyExecOption(value)
set.defaultFlagsOption(value)
set.suppressEchoCmdInFuncOption(value)

Arguments

ignore.stderr

default FALSE, can be set to TRUE to silence system() output to standard error; does not apply on Windows platforms

g.proj_WKT

default NULL: return WKT2 representation in GRASS >= 7.6 and Proj4 in GRASS < 7.6; may be set to FALSE to return Proj4 for GRASS >= 7.6

x

S3 object returned by gmeta

...

arguments passed through print method

value

logical value for setting options on ignore.stderr set by default on package load to FALSE, stop_on_no_flags_paras set by default on package load to TRUE, useGDAL set by default on package load to TRUE, plugin set by default on package load to NULL, echoCmd set by default on package load to FALSE. useIntern sets the intern argument globally; legacyExec sets the legacyExec option globally, but is initialized to FALSE on unix systems (all but Windows) and TRUE on Windows; defaultFlags is initialized to NULL, but may be a character vector with values from c("quiet", "verbose") suppressEchoCmdInFunc default TRUE suppresses the effect of echoCmd within package functions, may be set FALSE for debugging.

Value

Returns list of g.gisenv, g.region -g3, and g.proj values

Author

Roger S. Bivand, e-mail: Roger.Bivand@nhh.no.

Examples

use_sp() run <- FALSE if (nchar(Sys.getenv("GISRC")) > 0 && read.dcf(Sys.getenv("GISRC"))[1,"LOCATION_NAME"] == "nc_basic_spm_grass7") run <- TRUE if (run) { G <- gmeta() print(G) }
#> gisdbase /home/rsb/topics/grassdata #> location nc_basic_spm_grass7 #> mapset rsb #> rows 1350 #> columns 1500 #> north 228500 #> south 215000 #> west 630000 #> east 645000 #> nsres 10 #> ewres 10 #> projection: #> PROJCS["NAD83(HARN) / North Carolina", #> GEOGCS["NAD83(HARN)", #> DATUM["NAD83_High_Accuracy_Reference_Network", #> SPHEROID["GRS 1980",6378137,298.257222101, #> AUTHORITY["EPSG","7019"]], #> AUTHORITY["EPSG","6152"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4152"]], #> PROJECTION["Lambert_Conformal_Conic_2SP"], #> PARAMETER["latitude_of_origin",33.75], #> PARAMETER["central_meridian",-79], #> PARAMETER["standard_parallel_1",36.1666666666667], #> PARAMETER["standard_parallel_2",34.3333333333333], #> PARAMETER["false_easting",609601.22], #> PARAMETER["false_northing",0], #> UNIT["metre",1, #> AUTHORITY["EPSG","9001"]], #> AXIS["Easting",EAST], #> AXIS["Northing",NORTH], #> AUTHORITY["EPSG","3358"]]
if (run) { cat(getLocationProj(), "\n") }
#> PROJCS["NAD83(HARN) / North Carolina", #> GEOGCS["NAD83(HARN)", #> DATUM["NAD83_High_Accuracy_Reference_Network", #> SPHEROID["GRS 1980",6378137,298.257222101, #> AUTHORITY["EPSG","7019"]], #> AUTHORITY["EPSG","6152"]], #> PRIMEM["Greenwich",0, #> AUTHORITY["EPSG","8901"]], #> UNIT["degree",0.0174532925199433, #> AUTHORITY["EPSG","9122"]], #> AUTHORITY["EPSG","4152"]], #> PROJECTION["Lambert_Conformal_Conic_2SP"], #> PARAMETER["latitude_of_origin",33.75], #> PARAMETER["central_meridian",-79], #> PARAMETER["standard_parallel_1",36.1666666666667], #> PARAMETER["standard_parallel_2",34.3333333333333], #> PARAMETER["false_easting",609601.22], #> PARAMETER["false_northing",0], #> UNIT["metre",1, #> AUTHORITY["EPSG","9001"]], #> AXIS["Easting",EAST], #> AXIS["Northing",NORTH], #> AUTHORITY["EPSG","3358"]]
if (run) { cat(getLocationProj(g.proj_WKT=FALSE), "\n") }
#> +proj=lcc +lat_1=36.16666666666666 +lat_2=34.33333333333334 +lat_0=33.75 +lon_0=-79 +x_0=609601.22 +y_0=0 +no_defs +a=6378137 +rf=298.257222101 +towgs84=0.000,0.000,0.000 +type=crs +to_meter=1
if (run) { grd <- gmeta2grd() print(grd) }
#> X1 X2 #> cellcentre.offset 630005 215005 #> cellsize 10 10 #> cells.dim 1500 1350
if (run) { ncells <- prod(slot(grd, "cells.dim")) df <- data.frame(k=rep(1, ncells)) mask_SG <- sp::SpatialGridDataFrame(grd, data=df) print(summary(mask_SG)) }
#> Length Class Mode #> 2025000 SpatialGridDataFrame S4