Skip to content

Commit f131743

Browse files
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
1 parent d0995ce commit f131743

File tree

10 files changed

+74
-34
lines changed

10 files changed

+74
-34
lines changed

README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ Usage:
88
Script options:
99
-d, --dataset Geospatial dataset of interest, currently
1010
available options are: 'MODIS';
11-
'MERIT-Hydro';'SoilGridsV1'
11+
'MERIT-Hydro';'SoilGridsV1';'Landsat';
12+
'gsde';'depth-to-bedrock';
1213
-i, --dataset-dir=DIR The source path of the dataset file(s)
1314
-r, --crs=INT The EPSG code of interest; optional
1415
[defaults to 4326]
@@ -30,15 +31,17 @@ Script options:
3031
'min';'max';'mean';'majority';'minority';
3132
'median';'quantile';'variety';'variance';
3233
'stdev';'coefficient_of_variation';'frac';
33-
'coords'; optional
34+
'coords'; 'count'; optional
35+
-u, --include-na Include NA values in generated statistics;
36+
optional
3437
-q, --quantile=q1[,q2[...]] Quantiles of interest to be produced if 'quantile'
3538
is included in the '--stat' argument. The values
3639
must be comma delimited float numbers between
3740
0 and 1; optional [defaults to every 5th quantile]
3841
-p, --prefix=STR Prefix prepended to the output files
3942
-c, --cache=DIR Path of the cache directory; optional
4043
-E, --email=STR E-mail when job starts, ends, and
41-
finishes; optional
44+
fails; optional
4245
-V, --version Show version
4346
-h, --help Show this screen and exit
4447
```

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.1.0
1+
0.1.1

assets/stats.R

+13-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ vrt_path <- args[12];
3131
shapefile_path <- args[13];
3232
output_path <- args[14];
3333
stats <- args[15];
34-
quantiles <- args[16];
34+
include_na <- args[16];
35+
quantiles <- args[17];
3536

3637
# set the working directory path
3738
setwd(working_dir_path)
@@ -75,11 +76,21 @@ if (coord_var %in% s) {
7576
} else {
7677
include_coords = FALSE
7778
}
79+
7880
# extract ID column name
7981
id_col <- names(p[1])[1]
8082

83+
# check `na_values`
84+
if (include_na == 'true') {
85+
na_values = 9999
86+
print('Including NA values');
87+
} else {
88+
na_values = NA_real_
89+
print('NOT including NA values');
90+
}
91+
8192
# run exactextractr and calculate necessary stats
82-
df <- exactextractr::exact_extract(r, p, s, quantiles=q, append_cols=id_col); # assuming first column indicates ID
93+
df <- exactextractr::exact_extract(r, p, s, default_value=na_values, quantiles=q, append_cols=id_col); # assuming first column indicates ID
8394

8495
# extract centroid coordinates and prepend to `df`
8596
if (include_coords == TRUE) {

depth_to_bedrock/depth_to_bedrock.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
# Usage Functions
4242
# ===============
4343
short_usage() {
44-
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] "
44+
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] "
4545
}
4646

4747

4848
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
49-
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: -- "$@")
49+
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: -- "$@")
5050
validArguments=$?
5151
if [ "$validArguments" != "0" ]; then
5252
short_usage;
@@ -75,6 +75,7 @@ do
7575
-f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant
7676
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required
7777
-a | --stat) stats="$2" ; shift 2 ;; # optional
78+
-u | --include-na) includeNA="$2" ; shift 2 ;; # required
7879
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
7980
-p | --prefix) prefix="$2" ; shift 2 ;; # optional
8081
-c | --cache) cache="$2" ; shift 2 ;; # required
@@ -273,6 +274,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
273274
"$shapefile" \
274275
"$outputDir/${prefix}stats_${var}.csv" \
275276
"$stats" \
277+
"$includeNA" \
276278
"$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1;
277279
done
278280
fi

extract-gis.sh

+27-13
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
# Help functions
3737
# ==============
3838
usage () {
39-
echo "GISTOOL: Geospatial Dataset Processing Script
39+
echo "GISTOOL: Geospatial Data Processing Script
4040
4141
Usage:
4242
extract-gis [options...]
4343
4444
Script options:
4545
-d, --dataset Geospatial dataset of interest, currently
4646
available options are: 'MODIS';
47-
'MERIT-Hydro';'SoilGridsV1'
47+
'MERIT-Hydro';'SoilGridsV1';'Landsat';
48+
'gsde';'depth-to-bedrock';
4849
-i, --dataset-dir=DIR The source path of the dataset file(s)
4950
-r, --crs=INT The EPSG code of interest; optional
5051
[defaults to 4326]
@@ -66,26 +67,28 @@ Script options:
6667
'min';'max';'mean';'majority';'minority';
6768
'median';'quantile';'variety';'variance';
6869
'stdev';'coefficient_of_variation';'frac';
69-
'coords'; optional
70+
'coords'; 'count'; optional
71+
-u, --include-na Include NA values in generated statistics;
72+
optional
7073
-q, --quantile=q1[,q2[...]] Quantiles of interest to be produced if 'quantile'
7174
is included in the '--stat' argument. The values
7275
must be comma delimited float numbers between
7376
0 and 1; optional [defaults to every 5th quantile]
7477
-p, --prefix=STR Prefix prepended to the output files
7578
-c, --cache=DIR Path of the cache directory; optional
7679
-E, --email=STR E-mail when job starts, ends, and
77-
finishes; optional
80+
fails; optional
7881
-V, --version Show version
7982
-h, --help Show this screen and exit
8083
81-
For bug reports, questions, discussions open an issue
84+
For bug reports, questions, and discussions open an issue
8285
at https://github.com/kasra-keshavarz/gistool/issues" >&1;
8386

8487
exit 0;
8588
}
8689

8790
short_usage () {
88-
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;
91+
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;
8992
}
9093

9194
version () {
@@ -107,8 +110,11 @@ shopt -s expand_aliases
107110
# =======================
108111
# Parsing input arguments
109112
# =======================
110-
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
111-
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 -- "$@")
113+
# argument parsing using getopt -
114+
# ATTENTION: `getopt` is available by default on most GNU/Linux
115+
# distributions, however, it may not work out of the
116+
# box on MacOS or BSD
117+
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 -- "$@")
112118
validArguments=$?
113119
# check if there is no valid options
114120
if [ "$validArguments" != "0" ]; then
@@ -140,6 +146,7 @@ do
140146
-j | --submit-job) jobSubmission=true ; shift ;; # optional
141147
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # optional
142148
-a | --stat) stats="$2" ; shift 2 ;; # optional
149+
-u | --include-na) includeNA=true ; shift ;; # optional
143150
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
144151
-p | --prefix) prefixStr="$2" ; shift 2 ;; # required
145152
-c | --cache) cache="$2" ; shift 2 ;; # optional
@@ -174,6 +181,11 @@ if [[ -z $printGeotiff ]]; then
174181
printGeotiff=true
175182
fi
176183

184+
# if $includeNA is not triggered
185+
if [[ -z $includeNA ]]; then
186+
includeNA=false
187+
fi
188+
177189
# check the value of $printGeotiff
178190
if [[ -n $printGeotiff ]]; then
179191
case "${printGeotiff,,}" in
@@ -254,6 +266,7 @@ declare -A funcArgs=([geotiffDir]="$geotiffDir" \
254266
[jobSubmission]="$jobSubmission" \
255267
[printGeotiff]="$printGeotiff" \
256268
[stats]="$stats" \
269+
[includeNA]="$includeNA" \
257270
[quantiles]="$quantiles" \
258271
[prefixStr]="$prefixStr" \
259272
[cache]="$cache" \
@@ -274,13 +287,14 @@ call_processing_func () {
274287
# all processing script files must follow same input argument standard
275288
local scriptRun
276289
read -rd '' scriptRun <<- EOF
277-
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]}"
290+
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]}"
278291
EOF
279292

280293
# evaluate the script file using the arguments provided
281294
if [[ "${funcArgs[jobSubmission]}" == true ]]; then
282295
# Create a temporary directory for keeping job logs
283-
mkdir -p "$HOME/scratch/.gdt_logs"
296+
logDir="$HOME/scratch/.gistool_logs/"
297+
mkdir -p "$logDir"
284298
# SLURM batch file
285299
sbatch <<- EOF
286300
#!/bin/bash
@@ -290,15 +304,15 @@ call_processing_func () {
290304
#SBATCH --time=04:00:00
291305
#SBATCH --mem=16GB
292306
#SBATCH --job-name=GIS_${scriptName}
293-
#SBATCH --error=$HOME/scratch/.gdt_logs/GIS_%j_err.txt
294-
#SBATCH --output=$HOME/scratch/.gdt_logs/GIS_%j.txt
307+
#SBATCH --error=$logDir/GIS_%j_err.txt
308+
#SBATCH --output=$logDir/GIS_%j.txt
295309
#SBATCH --mail-user=$email
296310
#SBATCH --mail-type=BEGIN,END,FAIL
297311
298312
srun ${scriptRun} --cache="${cache}-\${SLURM_JOB_ID}"
299313
EOF
300314
# echo message
301-
echo "$(basename $0): job submission details are printed under ${HOME}/scratch/.gdt_logs"
315+
echo "$(basename $0): job submission details are printed under ${logDir}"
302316

303317
else
304318
eval "$scriptRun"

gsde/gsde.sh

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# GIS Data Processing Workflow
3-
# Copyright (C) 2022, University of Saskatchewan
3+
# Copyright (C) 2022-2023, University of Saskatchewan
4+
# Copyright (C) 2023, University of Calgary
45
# Copyright (C) 2021, Wouter Knoben
56
#
67
# This file is part of GIS Data Processing Workflow
@@ -40,12 +41,12 @@
4041
# Usage Functions
4142
# ===============
4243
short_usage() {
43-
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] "
44+
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] "
4445
}
4546

4647

4748
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
48-
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: -- "$@")
49+
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: -- "$@")
4950
validArguments=$?
5051
if [ "$validArguments" != "0" ]; then
5152
short_usage;
@@ -74,6 +75,7 @@ do
7475
-f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant
7576
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required
7677
-a | --stat) stats="$2" ; shift 2 ;; # optional
78+
-u | --include-na) includeNA="$2" ; shift 2 ;; # required
7779
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
7880
-p | --prefix) prefix="$2" ; shift 2 ;; # optional
7981
-c | --cache) cache="$2" ; shift 2 ;; # required
@@ -284,6 +286,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
284286
"$shapefile" \
285287
"$outputDir/${prefix}stats_${var}.csv" \
286288
"$stats" \
289+
"$includeNA" \
287290
"$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1;
288291
done
289292
fi

landsat/landsat.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
# Usage Functions
4242
# ===============
4343
short_usage() {
44-
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] "
44+
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] "
4545
}
4646

4747

4848
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
49-
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: -- "$@")
49+
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: -- "$@")
5050
validArguments=$?
5151
if [ "$validArguments" != "0" ]; then
5252
short_usage;
@@ -75,6 +75,7 @@ do
7575
-f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant
7676
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required
7777
-a | --stat) stats="$2" ; shift 2 ;; # optional
78+
-u | --include-na) includeNA="$2" ; shift 2 ;; # required
7879
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
7980
-p | --prefix) prefix="$2" ; shift 2 ;; # optional
8081
-c | --cache) cache="$2" ; shift 2 ;; # required
@@ -385,7 +386,8 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
385386
"$shapefile" \
386387
"$outputDir/${prefix}stats_${fileName[0]}.csv" \
387388
"$stats" \
388-
"$quantiles" >> "${outputDir}/${prefix}stats_${fileName[0]}.log" 2>&1;
389+
"$includeNA" \
390+
"$quantiles" >> "${outputDir}/${prefix}stats_${fileName[0]}.log" 2>&1;
389391
wait;
390392
done
391393
fi

merit_hydro/merit_hydro.sh

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@
4343
# Usage Functions
4444
# ===============
4545
short_usage() {
46-
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] "
46+
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] "
4747
}
4848

4949

5050
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
51-
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: -- "$@")
51+
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: -- "$@")
5252
validArguments=$?
5353
if [ "$validArguments" != "0" ]; then
5454
short_usage;
@@ -376,6 +376,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
376376
"$shapefile" \
377377
"$outputDir/${prefix}stats_${var}.csv" \
378378
"$stats" \
379+
"$includeNA" \
379380
"$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1;
380381
done
381382
fi

modis/modis.sh

+4-2
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@
4141
# Usage Functions
4242
# ===============
4343
short_usage() {
44-
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] "
44+
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] "
4545
}
4646

4747

4848
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
49-
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: -- "$@")
49+
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: -- "$@")
5050
validArguments=$?
5151
if [ "$validArguments" != "0" ]; then
5252
short_usage;
@@ -75,6 +75,7 @@ do
7575
-f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant
7676
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required
7777
-a | --stat) stats="$2" ; shift 2 ;; # optional
78+
-u | --include-na) includeNA="$2" ; shift 2 ;; # required
7879
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
7980
-p | --prefix) prefix="$2" ; shift 2 ;; # optional
8081
-c | --cache) cache="$2" ; shift 2 ;; # required
@@ -314,6 +315,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
314315
"$shapefile" \
315316
"$outputDir/${var}/${prefix}stats_${var}_${yr}.csv" \
316317
"$stats" \
318+
"$includeNA" \
317319
"$quantiles" >> "${outputDir}/${var}/${prefix}stats_${var}_${yr}.log" 2>&1;
318320
done
319321
done

soil_grids/soil_grids_v1.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Copyright (C) 2022-2023, University of Saskatchewan
55
# Copyright (C) 2023, University of Calgary
66
#
7-
# This file is part of GIS Data Processing Workflow
7+
# This file is part of Geospatial Data Processing Workflow
88
#
99
# This program is free software: you can redistribute it and/or modify
1010
# it under the terms of the GNU General Public License as published by
@@ -41,12 +41,12 @@
4141
# Usage Functions
4242
# ===============
4343
short_usage() {
44-
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] "
44+
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] "
4545
}
4646

4747

4848
# argument parsing using getopt - WORKS ONLY ON LINUX BY DEFAULT
49-
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: -- "$@")
49+
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: -- "$@")
5050
validArguments=$?
5151
if [ "$validArguments" != "0" ]; then
5252
short_usage;
@@ -75,6 +75,7 @@ do
7575
-f | --shape-file) shapefile="$2" ; shift 2 ;; # required - could be redundant
7676
-t | --print-geotiff) printGeotiff="$2" ; shift 2 ;; # required
7777
-a | --stat) stats="$2" ; shift 2 ;; # optional
78+
-u | --include-na) includeNA="$2" ; shift 2 ;; # required
7879
-q | --quantile) quantiles="$2" ; shift 2 ;; # optional
7980
-p | --prefix) prefix="$2" ; shift 2 ;; # optional
8081
-c | --cache) cache="$2" ; shift 2 ;; # required
@@ -272,6 +273,7 @@ if [[ -n "$shapefile" ]] && [[ -n $stats ]]; then
272273
"$shapefile" \
273274
"$outputDir/${prefix}stats_${var}.csv" \
274275
"$stats" \
276+
"$includeNA" \
275277
"$quantiles" >> "${outputDir}/${prefix}stats_${var}.log" 2>&1;
276278
done
277279
fi

0 commit comments

Comments
 (0)