|
@@ -40,6 +40,7 @@ struct menu
|
|
{c_stddev, 0, "stddev", "standard deviation"},
|
|
{c_stddev, 0, "stddev", "standard deviation"},
|
|
{c_range, 0, "range", "range of values"},
|
|
{c_range, 0, "range", "range of values"},
|
|
{c_sum, 0, "sum", "sum of values"},
|
|
{c_sum, 0, "sum", "sum of values"},
|
|
|
|
+ {c_thresh, 1, "threshold", "threshold value"},
|
|
{c_var, 0, "variance", "statistical variance"},
|
|
{c_var, 0, "variance", "statistical variance"},
|
|
{c_divr, 1, "diversity", "number of different values"},
|
|
{c_divr, 1, "diversity", "number of different values"},
|
|
{c_reg_m, 0, "slope", "linear regression slope"},
|
|
{c_reg_m, 0, "slope", "linear regression slope"},
|
|
@@ -68,6 +69,7 @@ struct output
|
|
DCELL *buf;
|
|
DCELL *buf;
|
|
stat_func *method_fn;
|
|
stat_func *method_fn;
|
|
double quantile;
|
|
double quantile;
|
|
|
|
+ double threshold;
|
|
};
|
|
};
|
|
|
|
|
|
static char *build_method_list(void)
|
|
static char *build_method_list(void)
|
|
@@ -107,7 +109,7 @@ int main(int argc, char *argv[])
|
|
struct GModule *module;
|
|
struct GModule *module;
|
|
struct
|
|
struct
|
|
{
|
|
{
|
|
- struct Option *input, *output, *method, *quantile, *range;
|
|
|
|
|
|
+ struct Option *input, *output, *method, *quantile, *threshold, *range;
|
|
} parm;
|
|
} parm;
|
|
struct
|
|
struct
|
|
{
|
|
{
|
|
@@ -155,6 +157,13 @@ int main(int argc, char *argv[])
|
|
parm.quantile->options = "0.0-1.0";
|
|
parm.quantile->options = "0.0-1.0";
|
|
parm.quantile->multiple = YES;
|
|
parm.quantile->multiple = YES;
|
|
|
|
|
|
|
|
+ parm.threshold = G_define_option();
|
|
|
|
+ parm.threshold->key = "threshold";
|
|
|
|
+ parm.threshold->type = TYPE_DOUBLE;
|
|
|
|
+ parm.threshold->required = NO;
|
|
|
|
+ parm.threshold->description = _("Threshold to calculate for method=threshold");
|
|
|
|
+ parm.threshold->multiple = YES;
|
|
|
|
+
|
|
parm.range = G_define_option();
|
|
parm.range = G_define_option();
|
|
parm.range->key = "range";
|
|
parm.range->key = "range";
|
|
parm.range->type = TYPE_DOUBLE;
|
|
parm.range->type = TYPE_DOUBLE;
|
|
@@ -215,6 +224,9 @@ int main(int argc, char *argv[])
|
|
out->quantile = (parm.quantile->answer && parm.quantile->answers[i])
|
|
out->quantile = (parm.quantile->answer && parm.quantile->answers[i])
|
|
? atof(parm.quantile->answers[i])
|
|
? atof(parm.quantile->answers[i])
|
|
: 0;
|
|
: 0;
|
|
|
|
+ out->threshold = (parm.threshold->answer && parm.threshold->answers[i])
|
|
|
|
+ ? atof(parm.threshold->answers[i])
|
|
|
|
+ : 0;
|
|
out->buf = Rast_allocate_d_buf();
|
|
out->buf = Rast_allocate_d_buf();
|
|
out->fd = Rast_open_new(output_name,
|
|
out->fd = Rast_open_new(output_name,
|
|
menu[method].is_int ? CELL_TYPE : DCELL_TYPE);
|
|
menu[method].is_int ? CELL_TYPE : DCELL_TYPE);
|
|
@@ -259,7 +271,7 @@ int main(int argc, char *argv[])
|
|
Rast_set_d_null_value(&out->buf[col], 1);
|
|
Rast_set_d_null_value(&out->buf[col], 1);
|
|
else {
|
|
else {
|
|
memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
|
|
memcpy(values_tmp, values, num_inputs * sizeof(DCELL));
|
|
- (*out->method_fn)(&out->buf[col], values_tmp, num_inputs, &out->quantile);
|
|
|
|
|
|
+ (*out->method_fn)(&out->buf[col], values_tmp, num_inputs, &out->threshold);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|