if (FALSE) {
library(link2GI)
require(sf)
# proj folders
projRootDir = tempdir()
paths = link2GI::initProj(projRootDir = projRootDir,
projFolders = c("project1/"))
# get data
nc = st_read(system.file("shape/nc.shp", package="sf"))
# Automatic search and find of GRASS binaries
# using the nc sf data object for spatial referencing
# This is the highly recommended linking procedure for on the fly jobs
# NOTE: if more than one GRASS installation is found you have to choose.
grass = linkGRASS(nc,returnPaths = TRUE)
if (grass$exist){
# CREATE and link to a permanent GRASS folder at "projRootDir", location named "project1"
linkGRASS(nc, gisdbase = projRootDir, location = "project1")
# ONLY LINK to a permanent GRASS folder at "projRootDir", location named "project1"
linkGRASS(gisdbase = projRootDir, location = "project1", gisdbase_exist = TRUE )
# setting up GRASS manually with spatial parameters of the nc data
proj4_string = as.character(sp::CRS("+init=epsg:28992"))
linkGRASS(spatial_params = c(178605,329714,181390,333611,proj4_string))
# creating a GRASS gisdbase manually with spatial parameters of the nc data
# additionally using a peramanent directory "projRootDir" and the location "nc_spatial_params "
proj4_string = as.character(sp::CRS("+init=epsg:4267"))
linkGRASS(gisdbase = projRootDir,
location = "nc_spatial_params",
spatial_params = c(-84.32385, 33.88199,-75.45698,36.58965,proj4_string))
}
## Some more examples related to interactive selection or OS specific settings
# SELECT the GRASS installation and define the search location
linkGRASS(nc, ver_select = TRUE, search_path = "~")
# SELECT the GRASS installation
linkGRASS(nc, ver_select = TRUE)
# Typical osge4W installation (QGIS), using the meuse sp data object for spatial referencing
linkGRASS(nc,c("C:/Program Files/QGIS 2.18","grass-7.2.1","osgeo4W"))
# Typical osgeo4W installation (rootdir), using the meuse sp data object for spatial referencing
linkGRASS(nc,c("C:/OSGeo4W64/","grass-7.2.2","osgeo4W"))
}
Run the code above in your browser using DataLab