executeGroovyFile: executeGrovyFile

Description Usage Arguments Examples

Description

Execute a Geoscript-groovy or Groovy Script File

Usage

1
2
3
4
5
6
executeGroovyFile(x, inputVar, outputVar = NULL, putOutputNames = FALSE,
  command = "jgrass-geoscript-groovy",
  command_path = system.file("geoscript-groovy-with-jgrasstools/bin", package
  = "rjgrassGroovySmartBridge"), generated.geoscript = paste("temp",
  "last_geoscript.groovy", sep = "/"), sys.setenv = list(GROOVY_HOME =
  "/usr/local/groovy-2.1.6:/opt/local:/usr"), verbose = TRUE, ...)

Arguments

x

a S3 ParsedGroovyScriptIOVar object

inputVar

list with input variables

outputVar

list with output variables

putOutputNames

logical argument. Default is FALSE. See putValueInScript.

command

string containing the Groovy command with necessary arguments.

command_path

string with the full path to the directory containing the command executable file. In Unix-like system,type which groovy to find the correct path.

generated.geoscript

file neme of the generated script run by command.

sys.setenv

list of environment variable settings required by command. See examples and usage. If NULL no environmental variables are set.

verbose

verbose modality. Default is TRUE.

...

further arguments

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
library(rjgrassGroovySmartBridge)


file <- system.file("geoscript-groovy/geomorphological.analysis.groovy",package="rjgrassGroovySmartBridge")
groovy <- parseGroovyFile(file=file)

dem  <- system.file("examples/match100m.asc",package="rjgrassGroovySmartBridge")

### INPUT VARIABLE
input <- list()
input$elevAsc <- dem
input$pThresScalar <- 10

## OUTPUT VARIABLE

###output <- list() 
outwpath <- system.file("temporary_output",package="rjgrassGroovySmartBridge")

output <- groovy[str_detect(unlist(lapply(X=groovy,FUN=function(x){attr(x,"io.type")})),"output")]

names_output <- names(output)
output <- lapply(X=names(output),FUN=function(x,outwpath){ 
   				out <- str_replace(x," ","_") 
					out <- paste("output",out,sep="_")
					out <- paste(outwpath,out,sep="/")
					extension <- "asc"
					if (str_detect(x,"Asc")) extension <- "asc"
					if (str_detect(x,"Shp")) extension <- "shp"
					out <- paste(out,extension,sep=".")
					return(out)

},outwpath=outwpath)

names(output) <- names_output

executeGroovyFile(groovy,inputVar=input,outputVar=output)

ecor/rjgrassSmartGroovyBridge documentation built on May 15, 2019, 10:06 p.m.