Something went wrong on our end
-
Francesco Sabatini authoredFrancesco Sabatini authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
cli_A98.r 1.78 KiB
library(optparse)
# ------------------------------------------------------------------------------
# defaults
# ------------------------------------------------------------------------------
default.ncores <- 32
default.typp <- "shp"
# ------------------------------------------------------------------------------
# parsing arguments
# ------------------------------------------------------------------------------
options <- list (
make_option(
opt_str = c("-c", "--cores"),
dest = "ncores",
type = "integer",
default = default.ncores,
help = paste0("number of CPU cores to use, defaults to ", default.ncores),
metavar = "4"
),
make_option(
opt_str = c("-t", "--typp"),
dest = "typp",
type = "character",
default = default.typp,
help = "Which data type? raster or shp",
metavar = "4"
)
)
parser <- OptionParser(
usage = "Rscript %prog [options] data dt_beals header output",
option_list = options,
description = "\nan awesome R script",
epilogue = "use with caution, the awesomeness might slap you in the face!"
)
cli <- parse_args(parser, positional_arguments = 4)
# ------------------------------------------------------------------------------
# assign a few shortcuts
# ------------------------------------------------------------------------------
x.shp <- cli$args[1]
myfunction <- cli$args[2]
output <- cli$args[3]
toextract <- cli$args[4]
typp <- cli$options$ncores
ncores <- cli$options$ncores
# ------------------------------------------------------------------------------
# actual program
# ------------------------------------------------------------------------------
source("A98_PredictorsExtract.R")
PredExtr( x.shp, myfunction, output, toextract, typp, ncores)