From f1317436288ffb268c35bb706652d8b88251fe11 Mon Sep 17 00:00:00 2001 From: Kasra Farmer <50383939+kasra-keshavarz@users.noreply.github.com> Date: Fri, 17 Feb 2023 17:01:20 -0700 Subject: [PATCH] Iss23 (#24) * Bumping version to v0.1.1 to add a minor feature of including NA values in printed stats * Adding feature to consider or not consider NA values in stats * adding NA values consideration feature * Updating long usage notice/message --- README.md | 9 ++++--- VERSION | 2 +- assets/stats.R | 15 +++++++++-- depth_to_bedrock/depth_to_bedrock.sh | 6 +++-- extract-gis.sh | 40 +++++++++++++++++++--------- gsde/gsde.sh | 9 ++++--- landsat/landsat.sh | 8 +++--- merit_hydro/merit_hydro.sh | 5 ++-- modis/modis.sh | 6 +++-- soil_grids/soil_grids_v1.sh | 8 +++--- 10 files changed, 74 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 30c3132..3bf3351 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,8 @@ Usage: Script options: -d, --dataset Geospatial dataset of interest, currently available options are: 'MODIS'; - 'MERIT-Hydro';'SoilGridsV1' + 'MERIT-Hydro';'SoilGridsV1';'Landsat'; + 'gsde';'depth-to-bedrock'; -i, --dataset-dir=DIR The source path of the dataset file(s) -r, --crs=INT The EPSG code of interest; optional [defaults to 4326] @@ -30,7 +31,9 @@ Script options: 'min';'max';'mean';'majority';'minority'; 'median';'quantile';'variety';'variance'; 'stdev';'coefficient_of_variation';'frac'; - 'coords'; optional + 'coords'; 'count'; optional + -u, --include-na Include NA values in generated statistics; + optional -q, --quantile=q1[,q2[...]] Quantiles of interest to be produced if 'quantile' is included in the '--stat' argument. The values must be comma delimited float numbers between @@ -38,7 +41,7 @@ Script options: -p, --prefix=STR Prefix prepended to the output files -c, --cache=DIR Path of the cache directory; optional -E, --email=STR E-mail when job starts, ends, and - finishes; optional + fails; optional -V, --version Show version -h, --help Show this screen and exit ``` diff --git a/VERSION b/VERSION index 6e8bf73..17e51c3 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.0 +0.1.1 diff --git a/assets/stats.R b/assets/stats.R index 802a950..42a3c45 100755 --- a/assets/stats.R +++ b/assets/stats.R @@ -31,7 +31,8 @@ vrt_path <- args[12]; shapefile_path <- args[13]; output_path <- args[14]; stats <- args[15]; -quantiles <- args[16]; +include_na <- args[16]; +quantiles <- args[17]; # set the working directory path setwd(working_dir_path) @@ -75,11 +76,21 @@ if (coord_var %in% s) { } else { include_coords = FALSE } + # extract ID column name id_col <- names(p[1])[1] +# check `na_values` +if (include_na == 'true') { + na_values = 9999 + print('Including NA values'); +} else { + na_values = NA_real_ + print('NOT including NA values'); +} + # run exactextractr and calculate necessary stats -df <- exactextractr::exact_extract(r, p, s, quantiles=q, append_cols=id_col); # assuming first column indicates ID +df <- exactextractr::exact_extract(r, p, s, default_value=na_values, quantiles=q, append_cols=id_col); # assuming first column indicates ID # extract centroid coordinates and prepend to `df` if (include_coords == TRUE) { diff --git a/depth_to_bedrock/depth_to_bedrock.sh b/depth_to_bedrock/depth_to_bedrock.sh index c594485..afad3d6 100755 --- a/depth_to_bedrock/depth_to_bedrock.sh +++ b/depth_to_bedrock/depth_to_bedrock.sh @@ -41,12 +41,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n depth-to-bedrock -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n depth-to-bedrock -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -75,6 +75,7 @@ do -f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA="$2" ; shift 2 ;; # required -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefix="$2" ; shift 2 ;; # optional -c | --cache) cache="$2" ; shift 2 ;; # required @@ -273,6 +274,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${prefix}stats_${var}.csv" \ "$stats" \ + "$includeNA" \ "$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1; done fi diff --git a/extract-gis.sh b/extract-gis.sh index ac1a1f8..c1f32d3 100755 --- a/extract-gis.sh +++ b/extract-gis.sh @@ -36,7 +36,7 @@ # Help functions # ============== usage () { - echo "GISTOOL: Geospatial Dataset Processing Script + echo "GISTOOL: Geospatial Data Processing Script Usage: extract-gis [options...] @@ -44,7 +44,8 @@ Usage: Script options: -d, --dataset Geospatial dataset of interest, currently available options are: 'MODIS'; - 'MERIT-Hydro';'SoilGridsV1' + 'MERIT-Hydro';'SoilGridsV1';'Landsat'; + 'gsde';'depth-to-bedrock'; -i, --dataset-dir=DIR The source path of the dataset file(s) -r, --crs=INT The EPSG code of interest; optional [defaults to 4326] @@ -66,7 +67,9 @@ Script options: 'min';'max';'mean';'majority';'minority'; 'median';'quantile';'variety';'variance'; 'stdev';'coefficient_of_variation';'frac'; - 'coords'; optional + 'coords'; 'count'; optional + -u, --include-na Include NA values in generated statistics; + optional -q, --quantile=q1[,q2[...]] Quantiles of interest to be produced if 'quantile' is included in the '--stat' argument. The values must be comma delimited float numbers between @@ -74,18 +77,18 @@ Script options: -p, --prefix=STR Prefix prepended to the output files -c, --cache=DIR Path of the cache directory; optional -E, --email=STR E-mail when job starts, ends, and - finishes; optional + fails; optional -V, --version Show version -h, --help Show this screen and exit -For bug reports, questions, discussions open an issue +For bug reports, questions, and discussions open an issue at https://github.com/kasra-keshavarz/gistool/issues" >&1; exit 0; } short_usage () { - echo "usage: $(basename $0) -d DATASET -io DIR -v var1[,var2,[...]] [-jVhE] [-t BOOL] [-c DIR] [-se DATE] [-r INT] [-ln REAL,REAL] [-f PATH} [-p STR] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] " >&1; + echo "usage: $(basename $0) -d DATASET -io DIR -v var1[,var2,[...]] [-jVhEu] [-t BOOL] [-c DIR] [-se DATE] [-r INT] [-ln REAL,REAL] [-f PATH] [-p STR] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] " >&1; } version () { @@ -107,8 +110,11 @@ shopt -s expand_aliases # ======================= # Parsing input arguments # ======================= -# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n extract-geotiff -o d:i:r:v:o:s:e:l:n:f:jt:a:q:p:c:EVh --long dataset:,dataset-dir:,crs:,variable:,output-dir:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,submit-job,print-geotiff:,stat:,quantile:,prefix:,cache:,email:,version,help -- "$@") +# argument parsing using getopt - +# ATTENTION: `getopt` is available by default on most GNU/Linux +# distributions, however, it may not work out of the +# box on MacOS or BSD +parsedArguments=$(getopt -a -n extract-geotiff -o d:i:r:v:o:s:e:l:n:f:jt:a:uq:p:c:EVh --long dataset:,dataset-dir:,crs:,variable:,output-dir:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,submit-job,print-geotiff:,stat:,include-na,quantile:,prefix:,cache:,email:,version,help -- "$@") validArguments=$? # check if there is no valid options if [ "$validArguments" != "0" ]; then @@ -140,6 +146,7 @@ do -j | --submit-job) jobSubmission=true ; shift ;; # optional -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # optional -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA=true ; shift ;; # optional -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefixStr="$2" ; shift 2 ;; # required -c | --cache) cache="$2" ; shift 2 ;; # optional @@ -174,6 +181,11 @@ if [[ -z $printGeotiff ]]; then printGeotiff=true fi +# if $includeNA is not triggered +if [[ -z $includeNA ]]; then + includeNA=false +fi + # check the value of $printGeotiff if [[ -n $printGeotiff ]]; then case "${printGeotiff,,}" in @@ -254,6 +266,7 @@ declare -A funcArgs=([geotiffDir]="$geotiffDir" \ [jobSubmission]="$jobSubmission" \ [printGeotiff]="$printGeotiff" \ [stats]="$stats" \ + [includeNA]="$includeNA" \ [quantiles]="$quantiles" \ [prefixStr]="$prefixStr" \ [cache]="$cache" \ @@ -274,13 +287,14 @@ call_processing_func () { # all processing script files must follow same input argument standard local scriptRun read -rd '' scriptRun <<- EOF - bash ${script} --dataset-dir="${funcArgs[geotiffDir]}" --crs="${funcArgs[crs]}" --variable="${funcArgs[variables]}" --output-dir="${funcArgs[outputDir]}" --start-date="${funcArgs[startDate]}" --end-date="${funcArgs[endDate]}" --lat-lims="${funcArgs[latLims]}" --lon-lims="${funcArgs[lonLims]}" --shape-file="${funcArgs[shapefile]}" --print-geotiff="${funcArgs[printGeotiff]}" --stat="${funcArgs[stats]}" --quantile="${funcArgs[quantiles]}" --prefix="${funcArgs[prefixStr]}" --cache="${funcArgs[cache]}" + bash ${script} --dataset-dir="${funcArgs[geotiffDir]}" --crs="${funcArgs[crs]}" --variable="${funcArgs[variables]}" --output-dir="${funcArgs[outputDir]}" --start-date="${funcArgs[startDate]}" --end-date="${funcArgs[endDate]}" --lat-lims="${funcArgs[latLims]}" --lon-lims="${funcArgs[lonLims]}" --shape-file="${funcArgs[shapefile]}" --print-geotiff="${funcArgs[printGeotiff]}" --stat="${funcArgs[stats]}" --include-na="${funcArgs[includeNA]}" --quantile="${funcArgs[quantiles]}" --prefix="${funcArgs[prefixStr]}" --cache="${funcArgs[cache]}" EOF # evaluate the script file using the arguments provided if [[ "${funcArgs[jobSubmission]}" == true ]]; then # Create a temporary directory for keeping job logs - mkdir -p "$HOME/scratch/.gdt_logs" + logDir="$HOME/scratch/.gistool_logs/" + mkdir -p "$logDir" # SLURM batch file sbatch <<- EOF #!/bin/bash @@ -290,15 +304,15 @@ call_processing_func () { #SBATCH --time=04:00:00 #SBATCH --mem=16GB #SBATCH --job-name=GIS_${scriptName} - #SBATCH --error=$HOME/scratch/.gdt_logs/GIS_%j_err.txt - #SBATCH --output=$HOME/scratch/.gdt_logs/GIS_%j.txt + #SBATCH --error=$logDir/GIS_%j_err.txt + #SBATCH --output=$logDir/GIS_%j.txt #SBATCH --mail-user=$email #SBATCH --mail-type=BEGIN,END,FAIL srun ${scriptRun} --cache="${cache}-\${SLURM_JOB_ID}" EOF # echo message - echo "$(basename $0): job submission details are printed under ${HOME}/scratch/.gdt_logs" + echo "$(basename $0): job submission details are printed under ${logDir}" else eval "$scriptRun" diff --git a/gsde/gsde.sh b/gsde/gsde.sh index fbc24a5..7f2e76c 100755 --- a/gsde/gsde.sh +++ b/gsde/gsde.sh @@ -1,6 +1,7 @@ #!/bin/bash # GIS Data Processing Workflow -# Copyright (C) 2022, University of Saskatchewan +# Copyright (C) 2022-2023, University of Saskatchewan +# Copyright (C) 2023, University of Calgary # Copyright (C) 2021, Wouter Knoben # # This file is part of GIS Data Processing Workflow @@ -40,12 +41,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n gsde -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n gsde -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -74,6 +75,7 @@ do -f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA="$2" ; shift 2 ;; # required -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefix="$2" ; shift 2 ;; # optional -c | --cache) cache="$2" ; shift 2 ;; # required @@ -284,6 +286,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${prefix}stats_${var}.csv" \ "$stats" \ + "$includeNA" \ "$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1; done fi diff --git a/landsat/landsat.sh b/landsat/landsat.sh index 2a16332..f8c0ae6 100755 --- a/landsat/landsat.sh +++ b/landsat/landsat.sh @@ -41,12 +41,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n landsat -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n landsat -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -75,6 +75,7 @@ do -f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA="$2" ; shift 2 ;; # required -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefix="$2" ; shift 2 ;; # optional -c | --cache) cache="$2" ; shift 2 ;; # required @@ -385,7 +386,8 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${prefix}stats_${fileName[0]}.csv" \ "$stats" \ - "$quantiles" >> "${outputDir}/${prefix}stats_${fileName[0]}.log" 2>&1; + "$includeNA" \ + "$quantiles" >> "${outputDir}/${prefix}stats_${fileName[0]}.log" 2>&1; wait; done fi diff --git a/merit_hydro/merit_hydro.sh b/merit_hydro/merit_hydro.sh index da47e8e..ee97db5 100755 --- a/merit_hydro/merit_hydro.sh +++ b/merit_hydro/merit_hydro.sh @@ -43,12 +43,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n merit_hydro -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n merit_hydro -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -376,6 +376,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${prefix}stats_${var}.csv" \ "$stats" \ + "$includeNA" \ "$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1; done fi diff --git a/modis/modis.sh b/modis/modis.sh index a92f7f5..a77c5ec 100755 --- a/modis/modis.sh +++ b/modis/modis.sh @@ -41,12 +41,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n modis -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n modis -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -75,6 +75,7 @@ do -f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA="$2" ; shift 2 ;; # required -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefix="$2" ; shift 2 ;; # optional -c | --cache) cache="$2" ; shift 2 ;; # required @@ -314,6 +315,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${var}/${prefix}stats_${var}_${yr}.csv" \ "$stats" \ + "$includeNA" \ "$quantiles" >> "${outputDir}/${var}/${prefix}stats_${var}_${yr}.log" 2>&1; done done diff --git a/soil_grids/soil_grids_v1.sh b/soil_grids/soil_grids_v1.sh index f1787b8..35e9cbd 100755 --- a/soil_grids/soil_grids_v1.sh +++ b/soil_grids/soil_grids_v1.sh @@ -4,7 +4,7 @@ # Copyright (C) 2022-2023, University of Saskatchewan # Copyright (C) 2023, University of Calgary # -# This file is part of GIS Data Processing Workflow +# This file is part of Geospatial Data Processing Workflow # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,12 +41,12 @@ # Usage Functions # =============== short_usage() { - echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-q q1[,q2[...]]]] [-p STR] " + echo "usage: $(basename $0) -cio DIR -v var1[,var2[...]] [-r INT] [-se DATE] [-ln REAL,REAL] [-f PATH] [-t BOOL] [-a stat1[,stat2,[...]] [-u BOOL] [-q q1[,q2[...]]]] [-p STR] " } # argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT -parsedArguments=$(getopt -a -n soil-grids-v1 -o i:o:v:r:s:e:l:n:f:t:a:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,quantile:,prefix:,cache: -- "$@") +parsedArguments=$(getopt -a -n soil-grids-v1 -o i:o:v:r:s:e:l:n:f:t:a:u:q:p:c: --long dataset-dir:,output-dir:,variable:,crs:,start-date:,end-date:,lat-lims:,lon-lims:,shape-file:,print-geotiff:,stat:,include-na:,quantile:,prefix:,cache: -- "$@") validArguments=$? if [ "$validArguments" != "0" ]; then short_usage; @@ -75,6 +75,7 @@ do -f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant -t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required -a | --stat) stats="$2" ; shift 2 ;; # optional + -u | --include-na) includeNA="$2" ; shift 2 ;; # required -q | --quantile) quantiles="$2" ; shift 2 ;; # optional -p | --prefix) prefix="$2" ; shift 2 ;; # optional -c | --cache) cache="$2" ; shift 2 ;; # required @@ -272,6 +273,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then "$shapefile" \ "$outputDir/${prefix}stats_${var}.csv" \ "$stats" \ + "$includeNA" \ "$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1; done fi