#' Start GIS.
#' Initializes the GIS environment
#' @examples
#' initGIS()
#' @export
initGIS<-function() {
library(rgrass7)
if (!file.exists(gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64")),fixed=T))){
downloadGIS()
}
#################################################################################
########### SETUP OSGEO4W enviroment settings manually
# setup the OSGEO4W environ manually
# assuming a osgeow4w default "deskop fastinstall
# using the default installation directory "C:\OSGeo4W64"
# set OSGE4W base directory
osgeo4w.root<-gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64")),fixed=T) #"C:\\PeelApps\\RandGIS\\OSGeo4W64"
Sys.setenv(OSGEO4W_ROOT=osgeo4w.root)
# define GISBASE
grass.gis.base<-paste0(osgeo4w.root,"\\apps\\grass\\grass-7.2.0")
Sys.setenv(GISBASE=grass.gis.base)
Sys.setenv(GRASS_PYTHON=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\bin\\python.exe"))
Sys.setenv(PYTHONHOME=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\apps\\Python27"))
Sys.setenv(PYTHONPATH=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\apps\\grass\\grass-7.2.0\\etc\\python"))
Sys.setenv(GRASS_PROJSHARE=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\share\\proj"))
Sys.setenv(PROJ_LIB=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\share\\proj"))
Sys.setenv(GDAL_DATA=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\share\\gdal"))
Sys.setenv(GEOTIFF_CSV=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\share\\epsg_csv"))
Sys.setenv(FONTCONFIG_FILE=paste0(Sys.getenv("OSGEO4W_ROOT"),"\\etc\\fonts.conf"))
# call all OSGEO4W settings
system(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/bin/o-help.bat"))
# create PATH variable
Sys.setenv(PATH=paste0(grass.gis.base,";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/Python27/lib/site-packages/numpy/core")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/grass/grass-7.2.0/bin")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/grass/grass-7.2.0/lib")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/grass/grass-7.2.0/etc")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/grass/grass-7.2.0/etc/python")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/Python27/Scripts")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/bin")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps")),fixed=T),";",
gsub("/","\\",(paste0(.libPaths(),"/RandGRASSGIS/OSGeo4W64/apps/saga")),fixed=T),";",
paste0(Sys.getenv("WINDIR"),"/WBem"),";",
Sys.getenv("PATH")))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.