[GRASS-SVN] r65539 - in grass-addons/grass7/vector/v.kriging: . images images/small
svn_grass at osgeo.org
svn_grass at osgeo.org
Sun Jul 5 07:28:14 PDT 2015
Author: evas
Date: 2015-07-05 07:28:14 -0700 (Sun, 05 Jul 2015)
New Revision: 65539
Added:
grass-addons/grass7/vector/v.kriging/images/
grass-addons/grass7/vector/v.kriging/images/small/
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_linear_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_spherical_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_15000.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_20000.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_1.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_2.png
grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_vertical_1200.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_rst.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_surfer.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_result_exponential.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_result_gauss.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_result_lid792_500.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_result_linear.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_result_spherical.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_exponential.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_gaussian.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_hz_100000.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_linear.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_surfer.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_linear.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_spherical.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_vertical_1600.png
grass-addons/grass7/vector/v.kriging/images/v_kriging_xvalid_rst_krig.png
Modified:
grass-addons/grass7/vector/v.kriging/geostat.c
grass-addons/grass7/vector/v.kriging/getval.c
grass-addons/grass7/vector/v.kriging/local_proto.h
grass-addons/grass7/vector/v.kriging/main.c
grass-addons/grass7/vector/v.kriging/spatial_index.c
grass-addons/grass7/vector/v.kriging/utils.c
grass-addons/grass7/vector/v.kriging/utils_kriging.c
grass-addons/grass7/vector/v.kriging/v.kriging.html
Log:
v.kriging: manual page + debugging
Modified: grass-addons/grass7/vector/v.kriging/geostat.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/geostat.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/geostat.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -86,7 +86,7 @@
double *dr; // coordinate differences of each couple
double *h; // distance of boundary of the horizontal segment
double tv; // bearing of the line between the couple of the input points
- double ddir; // the azimuth of computing variogram
+ double ddir1, ddir2; // the azimuth of computing variogram
double rv; // radius of the couple of points
double drv; // distance between the points
double rvh; // difference between point distance and the horizontal segment boundary
@@ -172,7 +172,7 @@
if (type == 2) {
vert = &var_pars->vertical.h[0];
}
-
+
/* *** Experimental variogram computation *** */
for (b = 0; b < ncols; b++) { // for each vertical lag...
if (type == 2) { // just in case that the variogram is vertical
@@ -222,10 +222,15 @@
}
else { // hz / aniso / bivar variogram:
tv = atan2(*(dr+1), *dr); // bearing
+ if (tv < 0.) {
+ tv += 2. * PI;
+ }
}
- ddir = tv - dir; // difference between bearing and azimuth
- if (fabsf(ddir) <= td) { // angle test: compare the diff with critical value
+ ddir1 = dir - tv; // difference between bearing and azimuth
+ ddir2 = (dir + PI) - tv;
+
+ if (fabsf(ddir1) <= td || fabsf(ddir2) <= td) { // angle test: compare the diff with critical value
// test squared distance: vertical variogram => 0., ...
rv = type == 1 ? 0. : radius_hz_diff(dr); // ... otherwise horizontal distance
@@ -336,11 +341,14 @@
// set up:
var_pars->type = type; // hz / vert / bivar / aniso
var_pars->const_val = 0; // input values are not constants
+
switch (type) {
case 0: // horizontal variogram
if (i3 == TRUE) { // 3D interpolation (middle phase)
variogram = opt.function_var_hz->answer; // function type available:
- if (strcmp(variogram, "linear") != 0) { // nonlinear
+ var_pars->function = set_function(variogram, report);
+
+ if (strcmp(variogram, "linear") != 0 && strcmp(variogram, "parabolic") != 0) { // nonlinear or not parabolic
var_pars->nugget = atof(opt.nugget_hz->answer);
var_pars->h_range = atof(opt.range_hz->answer);
if (opt.sill_hz->answer) {
@@ -348,12 +356,14 @@
}
}
else { // function type not available:
- linear_variogram(var_pars, report);
+ LMS_variogram(var_pars, report);
}
}
else { // 2D interpolation (final phase)
variogram = opt.function_var_final->answer; // function type available:
- if (strcmp(variogram, "linear") != 0) { // nonlinear
+ var_pars->function = set_function(variogram, report);
+
+ if (strcmp(variogram, "linear") != 0 && strcmp(variogram, "parabolic") != 0) { // nonlinear or not parabolic
var_pars->nugget = atof(opt.nugget_final->answer);
var_pars->h_range = atof(opt.range_final->answer);
if (opt.sill_final->answer) {
@@ -361,7 +371,7 @@
}
}
else { // function type not available:
- linear_variogram(var_pars, report);
+ LMS_variogram(var_pars, report);
}
}
@@ -380,6 +390,8 @@
var_pars->sill = atof(opt.sill_vert->answer);
}
variogram = opt.function_var_vert->answer;
+ var_pars->function = set_function(variogram, report);
+
if (report->name) {
fprintf(report->fp, "Parameters of vertical variogram:\n");
fprintf(report->fp, "Nugget effect: %f\n", var_pars->nugget);
@@ -390,7 +402,7 @@
case 2: // bivariate variogram (just final phase)
if (!(opt.function_var_final->answer && opt.function_var_final_vert->answer) || strcmp(opt.function_var_final->answer, "linear") == 0) { // planar function:
var_pars->function = 5; // planar variogram (3D)
- linear_variogram(var_pars, report);
+ LMS_variogram(var_pars, report);
}
else { // function type was set up by the user:
@@ -427,7 +439,9 @@
case 3: // univariate (just final phase)
variogram = opt.function_var_final->answer;
- if (strcmp(variogram, "linear") != 0) { // nonlinear variogram:
+ var_pars->function = set_function(variogram, report);
+
+ if (strcmp(variogram, "linear") != 0 && strcmp(variogram, "parabolic") != 0) { // nonlinear and not parabolic variogram:
var_pars->nugget = atof(opt.nugget_final->answer);
var_pars->h_range = atof(opt.range_final->answer);
if (opt.sill_final->answer) {
@@ -446,14 +460,13 @@
fprintf(report->fp, "Range: %f\n", var_pars->h_range);
}
}
- else {
- linear_variogram(var_pars, report);
+ else { // linear or parabolic variogram
+ LMS_variogram(var_pars, report);
}
break;
}
if (type != 2) {
- var_pars->function = set_function(variogram, report);
plot_var(i3, FALSE, var_pars); // Plot variogram using gnuplot
}
}
@@ -540,7 +553,7 @@
G_percent(row, reg->nrows, 1);
}
}
- //#pragma omp parallel for private(col, r0, cellCent, ind, sqDist, n1, GM, GM_Inv, g0, w0, rslt_OK)
+ //#pragma omp parallel for private(col, r0, GM, GM_Inv, g0, w0, rslt_OK)
for (col=0; col < reg->ncols; col++) {
if (var_par->const_val == 1) { // constant input values
@@ -556,11 +569,12 @@
list = find_NNs_within(3, r0, pnts, max_dist, max_dist_vert);
}
else { // 2D kriging:
- list = find_NNs_within(2, r0, pnts, 3. * max_dist, max_dist_vert);
+ list = find_NNs_within(2, r0, pnts, max_dist, max_dist_vert);
}
if (list->n_values > 1) { // positive # of selected points:
correct_indices(i3, list, r0, pnts, var_par);
+
GM_sub = submatrix(list, GM, report); // make submatrix for selected points
GM_Inv = G_matrix_inverse(GM_sub); // invert submatrix
G_matrix_free(GM_sub);
@@ -572,6 +586,7 @@
G_matrix_free(g0);
rslt_OK = result(pnts, list, w0); // Estimated cell/voxel value rslt_OK = w x inputs
+ G_matrix_free(w0);
}
else if (list->n_values == 1) {
rslt_OK = vals[list->value[0] - 1]; // Estimated cell/voxel value rslt_OK = w x inputs
@@ -584,6 +599,8 @@
G_fatal_error(_("This point does not have neighbours in given radius..."));
} // end else: error
+ G_free_ilist(list); // free list memory
+
// Create output
constant_voxel_val:
if (var_par->const_val == 1) { // constant input values:
@@ -598,8 +615,6 @@
}
G_fatal_error(_("Error writing result into output layer..."));
}
-
- G_free_ilist(list); // free list memory
} // end col
} // end row
} // end dep
Modified: grass-addons/grass7/vector/v.kriging/getval.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/getval.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/getval.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -26,10 +26,10 @@
else {
save = 1;
}
+
+ G_message(_("Reading values from attribute column <%s>..."), column);
- G_message(_("Reading values from attribute column <%s>..."), column);
db_CatValArray_init(&cvarr); /* array of categories and values initialised */
-
Fi = Vect_get_field(map, field); /* info about call of DB */
if (Fi == NULL) {
if (save == 1 && xD->report.write2file == TRUE) { // close report file
@@ -162,7 +162,7 @@
}
db_CatValArray_free(&cvarr); // free memory of the array of categories and values
-
+
return values;
}
@@ -340,6 +340,10 @@
G_fatal_error(_("Unable to read coordinates of point layer (all points are out of region)"));
}
+ if (out_reg > 0) {
+ G_message(_("Unused points: %d (out of region)"), out_reg);
+ }
+
if (xD->phase == 0) { // initial phase:
write2file_vector(xD, point); // describe properties
}
@@ -401,7 +405,7 @@
fp = fopen(file_name, "r");
if (fp == NULL) {
- G_fatal_error(_("File is missing..."));
+ G_fatal_error(_("Temporary file is missing, please repeat an initial phase..."));
}
else { // file exists:
@@ -545,4 +549,8 @@
}
}
fclose(fp);
+
+ if (xD->phase == 2) {
+ remove(file_name);
+ }
}
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_exponential_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_gauss_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_linear_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_linear_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_spherical_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_result_spherical_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_exponential_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_gauss_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_15000.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_15000.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_20000.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_hz_20000.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_linear_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_1.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_1.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_2.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_spherical_2.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_vertical_1200.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/small/v_kriging_variogram_vertical_1200.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_rst.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_rst.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_surfer.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_diff_lid792_500_surfer.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_exponential.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_exponential.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_gauss.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_gauss.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_lid792_500.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_lid792_500.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_linear.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_linear.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_spherical.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_result_spherical.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_exponential.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_exponential.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_gaussian.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_gaussian.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_hz_100000.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_hz_100000.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_linear.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_linear.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_surfer.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_lid792_500_surfer.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_linear.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_linear.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_spherical.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_spherical.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_vertical_1600.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_variogram_vertical_1600.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: grass-addons/grass7/vector/v.kriging/images/v_kriging_xvalid_rst_krig.png
===================================================================
(Binary files differ)
Property changes on: grass-addons/grass7/vector/v.kriging/images/v_kriging_xvalid_rst_krig.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: grass-addons/grass7/vector/v.kriging/local_proto.h
===================================================================
--- grass-addons/grass7/vector/v.kriging/local_proto.h 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/local_proto.h 2015-07-05 14:28:14 UTC (rev 65539)
@@ -205,6 +205,7 @@
void triple(double, double, double, double *);
double lag_size(int, struct int_par *, struct points *, struct parameters *, struct write *);
int lag_number(double, double *);
+void optimize(double *, int *, double);
void variogram_restricts(struct int_par *, struct points *, struct parameters *);
void geometric_anisotropy(struct int_par *, struct points *);
double find_intersect_x(double *, double *, double *, double *, struct write *);
@@ -216,7 +217,7 @@
void T_variogram(int, int, struct opts, struct parameters *, struct write *);
void ordinary_kriging(struct int_par *, struct reg_par *, struct points *, struct var_par *, struct output *);
-void linear_variogram(struct parameters *, struct write *);
+void LMS_variogram(struct parameters *, struct write *);
double bivar_sill(int, mat_struct *);
void sill(struct parameters *);
int sill_compare(struct int_par *, struct flgs *, struct var_par *, struct points *);
Modified: grass-addons/grass7/vector/v.kriging/main.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/main.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/main.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -149,7 +149,7 @@
opt.var_dir_hz->key = "azimuth";
opt.var_dir_hz->type = TYPE_DOUBLE;
opt.var_dir_hz->required = NO;
- opt.var_dir_hz->answer = "0.0";
+ opt.var_dir_hz->answer = "45.0";
opt.var_dir_hz->description =
_("Azimuth of variogram computing (isotrophic)");
opt.var_dir_hz->guisection = _("Initial");
@@ -181,7 +181,7 @@
opt.td_hz = G_define_option();
opt.td_hz->key = "td";
opt.td_hz->type = TYPE_DOUBLE;
- opt.td_hz->answer = "90.0";
+ opt.td_hz->answer = "45.0";
opt.td_hz->description = _("Angle of variogram processing");
opt.td_hz->required = NO;
opt.td_hz->guisection = _("Initial");
@@ -189,6 +189,7 @@
opt.nugget_hz = G_define_option();
opt.nugget_hz->key = "hz_nugget";
opt.nugget_hz->type = TYPE_DOUBLE;
+ opt.nugget_hz->answer = "0.0";
opt.nugget_hz->description = _("Nugget effect of horizontal variogram");
opt.nugget_hz->required = NO;
opt.nugget_hz->guisection = _("Middle");
@@ -196,6 +197,7 @@
opt.nugget_vert = G_define_option();
opt.nugget_vert->key = "vert_nugget";
opt.nugget_vert->type = TYPE_DOUBLE;
+ opt.nugget_vert->answer = "0.0";
opt.nugget_vert->description = _("Nugget effect of vertical variogram");
opt.nugget_vert->required = NO;
opt.nugget_vert->guisection = _("Middle");
@@ -203,7 +205,7 @@
opt.nugget_final = G_define_option();
opt.nugget_final->key = "final_nugget";
opt.nugget_final->type = TYPE_DOUBLE;
- opt.nugget_final->multiple = TRUE;
+ opt.nugget_final->answer = "0.0";
opt.nugget_final->description = _("Nugget effect of anisotropic variogram (or horizontal component of bivariate variogram)");
opt.nugget_final->required = NO;
opt.nugget_final->guisection = _("Final");
@@ -211,6 +213,7 @@
opt.nugget_final_vert = G_define_option();
opt.nugget_final_vert->key = "final_vert_nugget";
opt.nugget_final_vert->type = TYPE_DOUBLE;
+ opt.nugget_final_vert->answer = "0.0";
opt.nugget_final_vert->description = _("For bivariate variogram only: nuget effect of vertical component");
opt.nugget_final_vert->required = NO;
opt.nugget_final_vert->guisection = _("Final");
@@ -476,7 +479,7 @@
}
G_fatal_error(_("Please set up name of output layer..."));
}
-
+
// read properties of final variogram from temp file
if (xD.i3 == TRUE) { // 3D kriging:
read_tmp_vals("variogram_final_tmp.txt", &var_pars.fin, &xD);
@@ -491,7 +494,7 @@
if (xD.report.fp == NULL) // ... the file does not exist:
G_fatal_error(_("Cannot open the file..."));
}
-
+
// check variogram settings
if (var_pars.fin.type == 2 && strcmp(opt.function_var_final->answer, "linear") != 0) { // bivariate nonlinear variogram:
// just one function type is set up (none or both should be)
@@ -503,7 +506,7 @@
}
G_fatal_error(_("If you wish to specify components of bivariate variogram please set up function type for both of them..."));
}
-
+
// if both of the function types are set up:
if (opt.function_var_final->answer && opt.function_var_final_vert->answer) {
if (!opt.nugget_final->answer) { // horizontal nugget effect should not be missing
@@ -541,8 +544,8 @@
}
else { // univariate variogram
- if (xD.i3 == TRUE && strcmp(opt.function_var_final->answer, "linear") != 0) { // anisotropic 3D:
- if (opt.function_var_final_vert->answer || opt.nugget_final_vert->answer || opt.range_final_vert->answer) { // vertical settings available:
+ if (xD.i3 == TRUE && (strcmp(opt.function_var_final->answer, "linear") != 0 && strcmp(opt.function_var_final->answer, "parabolic") != 0)) { // anisotropic 3D:
+ if (opt.function_var_final_vert->answer || atof(opt.nugget_final_vert->answer) != 0. || opt.range_final_vert->answer) { // vertical settings available:
G_fatal_error(_("Not necessary to set up vertical components properties. Anisotropic variogram will be used..."));
} // end if vert settings available
} // end if 3D
@@ -552,13 +555,13 @@
G_message(_("Linear variogram will be computed..."));
}
- if (strcmp(opt.function_var_final->answer, "linear") != 0) { // nonlinear:
+ if (strcmp(opt.function_var_final->answer, "linear") != 0 && strcmp(opt.function_var_final->answer, "parabolic") != 0) { // nonlinear and not parabolic:
if (!opt.nugget_final->answer) { // missing horizontal nugget effect
if (xD.report.write2file == TRUE) { // report file available:
fprintf(xD.report.fp, "Error (see standard output). Process killed...");
fclose(xD.report.fp);
}
- G_fatal_error(_("Please set up nugget effect of horizontal component of bivariate variogram..."));
+ G_fatal_error(_("Please set up nugget effect..."));
} // end if nugget missing
if (!opt.range_final->answer) { // missing horizontal range:
@@ -566,9 +569,13 @@
fprintf(xD.report.fp, "Error (see standard output). Process killed...");
fclose(xD.report.fp);
}
- G_fatal_error(_("Please set up range of horizontal component of bivariate variogram..."));
+ G_fatal_error(_("Please set up range..."));
} // end if range missing
- }
+
+ if (opt.sill_final->answer) { // missing horizontal range:
+ var_pars.fin.sill = atof(opt.sill_final->answer);
+ } // end if sill has been changed by the user
+ } // end nonlinear and not parabolic variogram
} // end if univariate variogram (2D or 3D)
out.name = opt.output->answer; // Output layer name
@@ -578,6 +585,8 @@
}
T_variogram(var_pars.fin.type, xD.i3, opt, &var_pars.fin, &xD.report); // compute theoretical variogram
+
+ G_debug(0,"sill: %f", var_pars.fin.sill);
break;
}
Modified: grass-addons/grass7/vector/v.kriging/spatial_index.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/spatial_index.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/spatial_index.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -37,48 +37,61 @@
struct ilist *find_NNs_within(int dim, double *search_pt, struct points *pnts, double max_dist, double max_dist_vert)
{
// local variables
- double *r; // pointer to vector of the coordinates
- r = &search_pt[0];
+ double *r = search_pt; // pointer to vector of the coordinates
int NN_sum = 0; // # of NN
double dist_step = max_dist; // distance iteration in case of empty closest surrounding of search point
- double dist_step_vert = 0.1 * max_dist_vert; // vertical distance iteration
+ double dist_step_vert = max_dist_vert; // vertical distance iteration
struct RTree_Rect *search; // search rectangle
+
struct ilist *list;
list = G_new_ilist();
+ switch (dim) {
+ case 3:
+ search = RTreeAllocRect(pnts->R_tree); // allocate new rectangle
+ break;
+ case 2:
+ search = RTreeAllocRect(pnts->Rtree_hz); // allocate new rectangle
+ break;
+ case 1:
+ search = RTreeAllocRect(pnts->Rtree_vert); // allocate new rectangle
+ break;
+ }
+
while (NN_sum < 2) { // TODO: this might be tricky - what # (density) is optimal?
switch (dim) {
case 3: // 3D:
- search = RTreeAllocRect(pnts->R_tree); // allocate new rectangle
RTreeSetRect3D(search, pnts->R_tree,
*r - max_dist, *r + max_dist,
*(r+1) - max_dist, *(r+1) + max_dist,
- *(r+2) - max_dist_vert, *(r+2) + max_dist_vert); // set up searching rectangle
+ *(r+2) - max_dist_vert, *(r+2) + max_dist_vert); // set up searching rectangle
RTreeSearch2(pnts->R_tree, search, list); // search the nearest rectangle
break;
case 2: // 2D:
- search = RTreeAllocRect(pnts->Rtree_hz); // allocate new rectangle
RTreeSetRect2D(search, pnts->Rtree_hz,
*r - max_dist, *r + max_dist,
*(r+1) - max_dist, *(r+1) + max_dist); // set up searching rectangle
RTreeSearch2(pnts->Rtree_hz, search, list); // search the nearest rectangle
break;
case 1: // 1D:
- search = RTreeAllocRect(pnts->Rtree_vert); // allocate new rectangle
RTreeSetRect1D(search, pnts->Rtree_vert,
*(r+2) - max_dist_vert, *(r+2) + max_dist_vert); // set up searching rectangle
RTreeSearch2(pnts->Rtree_vert, search, list); // search the nearest rectangle
break;
}
- RTreeFreeRect(search);
NN_sum = list->n_values;
- max_dist += dist_step;
- max_dist_vert += dist_step_vert;
+ if (NN_sum < 2) {
+ G_warning(_("Point \"x=%f y=%f z=%f\" has less than 2 neighbours in its closest surrounding. The perimeter of the surrounding will be increased to include more neighbouring points"), *r, *(r+1), *(r+2));
+ max_dist += dist_step;
+ max_dist_vert += dist_step_vert;
+ }
} // end while: nonzero # of NNs
+ RTreeFreeRect(search);
+
return list;
}
Modified: grass-addons/grass7/vector/v.kriging/utils.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/utils.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/utils.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -134,8 +134,6 @@
double dist2; // square of the distances between search point and NN
double *search; // search point
- search = (double *) G_malloc(3 * sizeof(double));
-
int perc5; // 5% from total number of NN
int add_ident; // number of identical points to add to perc5
@@ -272,6 +270,16 @@
return n;
}
+void optimize(double *lag, int *nLag, double max)
+{
+ if (*nLag > 20) {
+ *nLag = 20;
+ *lag = max / *nLag;
+ }
+
+ return;
+}
+
// maximal horizontal and vertical distance to restrict variogram computing
void variogram_restricts(struct int_par *xD, struct points *pnts, struct parameters *var_pars)
{
@@ -329,17 +337,20 @@
// horizontal direction:
var_pars->lag = lag_size(12, xD, pnts, var_pars, report); // lag distance
var_pars->nLag = lag_number(var_pars->lag, &var_pars->max_dist); // number of lags
+ optimize(&var_pars->lag, &var_pars->nLag, var_pars->max_dist);
var_pars->max_dist = var_pars->nLag * var_pars->lag; // maximum distance
// vertical direction
var_pars->lag_vert = lag_size(3, xD, pnts, var_pars, report); // lag distance
var_pars->nLag_vert = lag_number(var_pars->lag_vert, &var_pars->max_dist_vert); // # of lags
+ optimize(&var_pars->lag_vert, &var_pars->nLag_vert, var_pars->max_dist_vert);
var_pars->max_dist_vert = var_pars->nLag_vert * var_pars->lag_vert; // max distance
}
else { // univariate variograms (hz / vert / aniso)
var_pars->lag = lag_size(dimension, xD, pnts, var_pars, report); // lag size
var_pars->nLag = lag_number(var_pars->lag, &var_pars->max_dist); // # of lags
+ optimize(&var_pars->lag, &var_pars->nLag, var_pars->max_dist);
var_pars->max_dist = var_pars->nLag * var_pars->lag; // maximum distance
}
@@ -601,7 +612,7 @@
switch (bivar) {
case FALSE: // univariate variogram
function = var_pars->function;
- if (function > 0) { // nonlinear variogram
+ if (function > 1) { // nonlinear and not parabolic variogram
nugget = var_pars->nugget;
sill = var_pars->sill - nugget;
h_range = var_pars->h_range;
@@ -697,7 +708,7 @@
switch (function) {
case 0: // linear
- dd = *T * hh + *(T+1);
+ dd = *T * hh; // todo: add nugget effect
break;
case 1: // parabolic
dd = *T * SQUARE(hh) + *(T+1);
@@ -820,44 +831,47 @@
}
else { // univariate variogram
- if (i3 == TRUE) { // 3D
+ if (i3 == TRUE) { // 3D variogram
if (var_pars->type == 0) { // horizontal variogram
- fprintf(gp, "set title \"Experimental and theoretical variogram (3D hz) of <%s>\"\n", var_pars->name);
- //fprintf(gp, "set label \"linear: gamma(h) = %f*h + %f\" at screen 0.30,0.90\n", var_par->T->vals[0], var_par->T->vals[1]);
+ if (i3 == TRUE) {
+ fprintf(gp, "set title \"Experimental and theoretical variogram (3D hz) of <%s>\"\n", var_pars->name);
+ }
+ else {
+ fprintf(gp, "set title \"Experimental and theoretical variogram (2D hz) of <%s>\"\n", var_pars->name);
+ }
}
else if (var_pars->type == 1) { // vertical variogram
fprintf(gp, "set title \"Experimental and theoretical variogram (3D vert) of <%s>\"\n", var_pars->name);
- //fprintf(gp, "set label \"linear: gamma(h) = %f*h + %f\" at screen 0.30,0.90\n", var_par->T->vals[0], var_par->T->vals[1]);
}
- else if (var_pars->type == 3) // anisotropic variogram
+ else if (var_pars->type == 3) {// anisotropic variogram
fprintf(gp, "set title \"Experimental and theoretical variogram (3D) of <%s>\"\n", var_pars->name);
+ }
}
else { // 2D
fprintf(gp, "set title \"Experimental and theoretical variogram (2D) of <%s>\"\n", var_pars->name);
}
- if (var_pars->type == 2) {
- switch (var_pars->function) {
- case 0: // linear
- fprintf(gp, "set label \"linear: gamma(h) = %f*h + %f\" at screen 0.30,0.90\n", var_pars->T->vals[0], var_pars->T->vals[1]);
- break;
- case 1: // parabolic
- fprintf(gp, "set label \"parabolic: gamma(h) = %f*h^2 + %f\" at screen 0.25,0.90\n", var_pars->T->vals[0], var_pars->T->vals[1]);
- break;
- case 2: // exponential
- fprintf(gp, "set rmargin 5\n");
- fprintf(gp, "set label \"exponential: gamma(h) = %f + %f * (1 - exp(-3*h / %f))\" at screen 0.10,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range);
- break;
- case 3: // spherical
- fprintf(gp, "set rmargin 5\n");
- fprintf(gp, "set label \"spherical: gamma(h) = %f+%f*(1.5*h/%f-0.5*(h/%f)^3)\" at screen 0.05,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range, var_pars->h_range);
- break;
- case 4: // gaussian
- fprintf(gp, "set label \"gaussian: gamma(h) = %f + %f * (1 - exp(-3*(h / %f)^2))\" at screen 0.10,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range);
- break;
- }
+ switch (var_pars->function) {
+ case 0: // linear
+ fprintf(gp, "set label \"linear: gamma(h) = %f*h\" at screen 0.30,0.90\n", var_pars->T->vals[0]);
+ break;
+ case 1: // parabolic
+ fprintf(gp, "set label \"parabolic: gamma(h) = %f*h^2\" at screen 0.25,0.90\n", var_pars->T->vals[0]);
+ break;
+ case 2: // exponential
+ fprintf(gp, "set rmargin 5\n");
+ fprintf(gp, "set label \"exponential: gamma(h) = %f + %f * (1 - exp(-3*h / %f))\" at screen 0.10,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range);
+ break;
+ case 3: // spherical
+ fprintf(gp, "set rmargin 5\n");
+ fprintf(gp, "set label \"spherical: gamma(h) = %f+%f*(1.5*h/%f-0.5*(h/%f)^3)\" at screen 0.05,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range, var_pars->h_range);
+ break;
+ case 4: // gaussian
+ fprintf(gp, "set label \"gaussian: gamma(h) = %f + %f * (1 - exp(-3*(h / %f)^2))\" at screen 0.10,0.90\n", var_pars->nugget, var_pars->sill - var_pars->nugget, var_pars->h_range);
+ break;
}
+
fprintf(gp, "set xlabel \"h [m]\"\n");
fprintf(gp, "set ylabel \"gamma(h) [units^2]\"\n");
fprintf(gp, "set key bottom right\n");
Modified: grass-addons/grass7/vector/v.kriging/utils_kriging.c
===================================================================
--- grass-addons/grass7/vector/v.kriging/utils_kriging.c 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/utils_kriging.c 2015-07-05 14:28:14 UTC (rev 65539)
@@ -5,14 +5,14 @@
return x*x;
}
-void linear_variogram(struct parameters *var_par, struct write *report)
+void LMS_variogram(struct parameters *var_par, struct write *report)
{
int nZ, nL; // # of gamma matrix rows and columns
int nr, nc; // # of plan matrix rows and columns
int i, j; // indices
double *h, *vert, *gamma;
- mat_struct *gR;
-
+ mat_struct *gR;
+
nL = var_par->gamma->rows; // # of cols (horizontal bins)
nZ = var_par->gamma->cols; // # of rows (vertical bins)
gamma = &var_par->gamma->vals[0]; // pointer to experimental variogram
@@ -28,8 +28,8 @@
} // end j
} // end i
- // Number of columns of design matrix A
- nc = var_par->function == 5 ? 3 : 2;
+ // # of columns of design matrix A
+ nc = var_par->function == 5 ? 3 : 1;
var_par->A = G_matrix_init(nr, nc, nr); // initialise design matrix
gR = G_matrix_init(nr, 1, nr); // initialise vector of observations
@@ -47,18 +47,21 @@
for (j = 0; j < nL; j++) {
if (!isnan(*gamma)) { // write to matrix - each valid element of gamma
switch (var_par->function) { // function of theoretical variogram
+ case 0: // linear variogram
+ G_matrix_set_element(var_par->A, nr, 0, *h);
+ //G_matrix_set_element(var_par->A, nr, 1, 1.);
+ break;
+ case 1: // parabolic variogram
+ G_matrix_set_element(var_par->A, nr, 0, SQUARE(*h));
+ G_matrix_set_element(var_par->A, nr, 1, 1.);
+ break;
case 5: // bivariate planar
G_matrix_set_element(var_par->A, nr, 0, *h);
G_matrix_set_element(var_par->A, nr, 1, *vert);
G_matrix_set_element(var_par->A, nr, 2, 1.);
- G_matrix_set_element(gR, nr, 0, *gamma);
break;
- default:
- G_matrix_set_element(var_par->A, nr, 0, *h);
- G_matrix_set_element(var_par->A, nr, 1, 1.);
- G_matrix_set_element(gR, nr, 0, *gamma);
- break;
} // end switch variogram fuction
+ G_matrix_set_element(gR, nr, 0, *gamma);
nr++; // length of vector of valid elements (not null)
} // end test if !isnan(*gamma)
h++;
@@ -83,17 +86,17 @@
} // error
// constant raster
- if (var_par->T->vals[0] == 0. && var_par->T->vals[1] == 0.) { //to do: otestuj pre 2d
+ if (var_par->T->vals[0] == 0. && var_par->T->vals[1] == 0.) {
var_par->const_val = 1;
G_message(_("Input values to be interpolated are constant."));
- } // todo: cnstant raster for exponential etc.
+ } // todo: constant raster for exponential etc.
// coefficients of theoretical variogram (linear)
if (report->name) {
fprintf(report->fp, "Parameters of bivariate variogram:\n");
fprintf(report->fp, "Function: linear\n\n");
fprintf(report->fp, "gamma(h, vert) = %f * h + %f * vert + %f\n", var_par->T->vals[0], var_par->T->vals[1], var_par->T->vals[2]);
- }
+ } // end if: report
}
double bivar_sill(int direction, mat_struct *gamma)
@@ -552,6 +555,7 @@
for (i=0; i<n; i++) { // for each input point:
*vt = *vo; // subval = selected original
*wt = *wo; // sub weight = selected original
+ //G_debug(0,"%f %f", *vt, *wt);
// go to the next:
if (n_ind == 0) { // use all points:
@@ -630,10 +634,10 @@
if (n_vals > 0 ) { // if positive:
correct_indices(i3, list, r, pnts, var_par);
- GM_sub = submatrix(list, GM, &xD->report); // create submatrix using indices
+ GM_sub = submatrix(list, GM, &xD->report); // create submatrix using indices
GM_Inv = G_matrix_inverse(GM_sub); // inverse matrix
G_matrix_free(GM_sub);
-
+
g0 = set_up_g0(xD, pnts, list, r, var_par); // Diffs inputs - unknowns (incl. cond. 1))
w0 = G_matrix_product(GM_Inv, g0); // Vector of weights, condition SUM(w) = 1 in last row
@@ -644,7 +648,7 @@
G_matrix_free(w0);
//Create output
- *norm = *vals - rslt_OK; // differences between input and interpolated values
+ *norm = rslt_OK - *vals; // differences between input and interpolated values
*av = fabsf(*norm); // absolute values of the differences (quantile computation)
if (xD->i3 == TRUE) { // 3D interpolation:
Modified: grass-addons/grass7/vector/v.kriging/v.kriging.html
===================================================================
--- grass-addons/grass7/vector/v.kriging/v.kriging.html 2015-07-03 01:30:05 UTC (rev 65538)
+++ grass-addons/grass7/vector/v.kriging/v.kriging.html 2015-07-05 14:28:14 UTC (rev 65539)
@@ -3,7 +3,14 @@
<em>v.kriging</em> interpolates unknown values using method <i>ordinary
kriging</i>. Output can be 2D or 3D.
-<h2>EXAMPLES</h2> Input layer should contain 3D coordinates (xyz) and
+<h2>EXAMPLES</h2>
+Two case studies have been prepared to outline that there is no universal rule how to use the module <i>v.kriging</i>.
+Bahaviour of the phenomena is quite variable and this influences how to interpolate the dataset properly. Every point
+dataset is special and requires trying different anisotropic ratios, variogram functions and careful analysis of
+the results to get relevant interpolated (2D / 3D) raster model.
+
+<h3>3D kriging</h3>
+Input layer should contain 3D coordinates (xyz) and
values to be interpolated (in attribute table). The commands can look
like this:
@@ -11,16 +18,1094 @@
v.kriging phase=initial in=input_layer icol=name report=report_file.txt file=png
</pre></div>
<div class="code"><pre>
-v.kriging in=input_layer phase=middle hz_fun=exponential vert_fun=exponential \
- ic=name file=png hz_nugget=0 vert_nugget=0 hz_range=double vert_range=double -b
+v.kriging in=input_layer phase=middle hz_fun=exponential vert_fun=exponential ic=name file=png hz_range=double vert_range=double -b
</pre></div>
<div class="code"><pre>
-v.kriging in=input_layer phase=final final_fun=bivariate icol=name file=png \
- out=name crossval=crossval_file.txt
+v.kriging in=input_layer phase=final final_fun=bivariate icol=name file=png out=name crossval=crossval_file.txt
</pre></div>
+<p>In the middle phase, there is possible also to modify nugget effect (default: 0.0) and sill (default: calculated from
+variogram values, more details in (<i>Stopkova, 2014</i>).
+
+<h4>Case study: Slovakia 3D precipitation</h4>
+<p>
+The case study is based on the input points of annual precipitation <a href="http://grass.osgeo.org/download/sample-data/" target="_blank">dataset</a>.
+Although positions of the points are given in three-dimensional space, the points are concentrated at the terrain and thus
+interpolation above and below the terrain would become imprecise in deeper / higher areas of the dataset. That is the reason
+to test just cross-section from interpolated 3D raster comparing it with cross-section from the RST result obtained using
+<a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a> according to (<i>Neteler and Mitasova, 2004</i>).
+
+<p>As the algorithm still needs to be optimized for large datasets, the original region was used with lower resolution
+(hz: 5000 m, vert: 500 m). To test also original resolution, the points in smaller region (<b>Tab. 1</b>) were extracted.
+
+<p>
+<table border="1">
+ <tr>
+ <td colspan="2" align="center">N = 5 468 000 m</td>
+ </tr>
+ <tr>
+ <td>W = 4 361 000 m</td>
+ <td>E = 4 465 500 m</td>
+ </tr>
+ <tr>
+ <td colspan="2" align="center">S = 5 374 500 m</td>
+ </tr>
+ <tr>
+ <td>top: 2 250 m</td>
+ <td>bottom: 200 m</td>
+ </tr>
+ <caption>
+ <b>Tab. 1:</b> Smaller region extent (resolution hz: 500 m, vert: 50 m)
+ </caption>
+</table>
+
+<p>
+In the initial phase, <b>experimental variograms</b> (horizontal and vertical) were computed:
+<div class="code"><pre>
+v.kriging phase=initial in=precip3d at PERMANENT ic=precip report=precip3d.txt file=png --o
+</pre></div>
+
+In the middle phase, there were empirically estimated types of the function and coefficients of <b>theoretical variograms</b>:
+<div class="code"><pre>
+v.kriging in=precip3d at PERMANENT phase=middle hz_fun=exponential vert_fun=gaussian ic=precip file=png hz_range=100000. vert_range=1600 --o -u
+</pre></div>
+
+<p>
+<table>
+ <tr>
+ <td>
+ <b>Fig. 1:</b> Experimental and theoretical variograms in horiontl and vertical direction<br>
+ left: whole region; middle: small region; right: small region with modified horizontal range
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/v_kriging_variogram_hz_100000.png" alt="var_hz_initial" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_hz_20000.png" alt="var_hz_small_initial" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_hz_15000.png" alt="var_hz_small_add" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+</table>
+
+<table>
+ <tr>
+ <td>
+ <img src="images/v_kriging_variogram_vertical_1600.png" alt="var_vert" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_vertical_1200.png" alt="var_vert_add" style="float: left; width: 24%; margin-left: 12%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+</table>
+
+The final phase results into theoretical variogram and interpolated values of the 3D raster:
+<div class="code"><pre>
+v.kriging in=precip3d at PERMANENT phase=middle hz_fun=exponential vert_fun=gaussian ic=precip \
+file=png hz_range=100000. vert_range=1600 --o -u
+</pre></div>
+
+<b>Cross validation</b> results of all the interpolated 3D rasters were compared. RST interpolation was performed using
+modified settings according to (<i>Neteler and Mitasova, 2004</i>, page 173) - different tension and smoothing parameters were set up to obtain more accurate cross
+validation results:
+
+<div class="code"><pre>
+v.vol.rst -c input="precip3d at PERMANENT" wcolumn="precip" tension=100. smooth=0. \
+cvdev="cxvalidation_rst_final" segmax=50 npmin=200 npmax=700 wscale=1.0 zscale=50
+</pre></div>
+
+<table>
+ <tr>
+ <td>
+ <img src="images/v_kriging_variogram_linear.png" alt="linear" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_variogram_exponential.png" alt="exponential" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_variogram_spherical.png" alt="spherical" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_variogram_gaussian.png" alt="gaussian" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ </tr>
+ <caption>
+ <b>Fig. 2:</b> Variogram modelling of the whole region with horizontal range of 100 000 m and vertical range of 1 600 m
+ </caption>
+</table>
+
+<table border="1" style="text-align: right;">
+ <tr>
+ <td></td>
+ <td align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td align="center">Linear</td>
+ <td align="center">Exponential</td>
+ <td align="center">Spherical</td>
+ <td align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>-816.805</td>
+ <td>-684.258</td>
+ <td>-686.063</td>
+ <td>-683.580</td>
+ <td>-741.081</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>175.831</td>
+ <td>429.597</td>
+ <td>424.419</td>
+ <td>424.228</td>
+ <td>444.747</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>0.171</td>
+ <td>0.131</td>
+ <td>0.699</td>
+ <td>0.653</td>
+ <td>0.721</td>
+ </tr>
+ <tr>
+ <td align="left">Variance [mm<sup>2</sup>]</td>
+ <td>9876.69</td>
+ <td>5740.89</td>
+ <td>5926.62</td>
+ <td>5950.70</td>
+ <td>5979.79</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>99.381</td>
+ <td>75.769</td>
+ <td>76.985</td>
+ <td>77.141</td>
+ <td>77.329</td>
+ </tr>
+ <caption>
+ <b>Tab. 2:</b> Cross validation of the whole region with horizontal range of 100 000 m and vertical range of 1 600 m
+ </caption>
+</table>
+
+<p>
+<table>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_variogram_linear.png" alt="small_linear" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_exponential.png" alt="small_exp" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_spherical.png" alt="small_spher" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_gauss.png" alt="small_gauss" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 3:</b> Variogram modelling of small region with horizontal range of 20 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<table border="1" style="text-align: right;">
+ <tr>
+ <td></td>
+ <td align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td align="center">Linear</td>
+ <td align="center" style="color: greenyellow;">Exponential</td>
+ <td align="center">Spherical</td>
+ <td align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>-908.303</td>
+ <td>-709.02</td>
+ <td>-755.531</td>
+ <td>-678.237</td>
+ <td>-786.613</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>257.69</td>
+ <td>420.689</td>
+ <td>340.874</td>
+ <td>384.109</td>
+ <td>315.248</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>0.554</td>
+ <td>0.908</td>
+ <td style="color: greenyellow;">-0.310</td>
+ <td>1.102</td>
+ <td>-0.739</td>
+ </tr>
+ <tr>
+ <td align="left">Variance [mm<sup>2</sup>]</td>
+ <td>28891.6</td>
+ <td>15638.7</td>
+ <td>21259.5</td>
+ <td>19754.8</td>
+ <td>21243.2</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>169.975</td>
+ <td>125.055</td>
+ <td>145.806</td>
+ <td>140.552</td>
+ <td>145.751</td>
+ </tr>
+ <caption>
+ <b>Tab. 3:</b> Cross validation of small region <br>with horizontal range of 20 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<p>
+<table>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_variogram_linear_1.png" alt="small_linear_1" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_exponential_1.png" alt="small_exp_1" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_spherical_1.png" alt="small_spher_1" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_gauss_1.png" alt="small_gauss_1" style="float: left; width: 24%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 4:</b> Variogram modelling of small region with horizontal range of 15 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<table border="1" style="text-align: right;">
+ <tr>
+ <td></td>
+ <td align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td align="center" style="color: greenyellow;">Linear</td>
+ <td align="center">Exponential</td>
+ <td align="center">Spherical</td>
+ <td align="center" style="color: greenyellow;">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>-908.303</td>
+ <td>-711.755</td>
+ <td>-756.805</td>
+ <td>-687.44</td>
+ <td>-529.702</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>257.69</td>
+ <td>397.666</td>
+ <td>326.057</td>
+ <td>357.990</td>
+ <td>425.637</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>0.554</td>
+ <td style="color: greenyellow;">0.208</td>
+ <td>-1.775</td>
+ <td>1.823</td>
+ <td style="color: greenyellow;">0.008</td>
+ </tr>
+ <tr>
+ <td align="left">Variance [mm<sup>2</sup>]</td>
+ <td>28891.6</td>
+ <td>15873</td>
+ <td>21438.5</td>
+ <td>20930.9</td>
+ <td>20473.1</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>169.975</td>
+ <td>125.988</td>
+ <td>146.419</td>
+ <td>144.675</td>
+ <td>143.084</td>
+ </tr>
+ <caption>
+ <b>Tab. 4:</b> Cross validation of small region <br>with horizontal range of 15 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<p>
+<p>
+<table>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_variogram_exponential_2.png" alt="small_exp_2" style="float: left; width: 32%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_spherical_2.png" alt="small_spher_2" style="float: left; width: 32%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_variogram_gauss_2.png" alt="small_gauss_2" style="float: left; width: 32%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 5:</b> Variogram modelling of small region with horizontal range of 15 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<table border="1" style="text-align: right;">
+ <tr>
+ <td></td>
+ <td align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td align="center">Exponential</td>
+ <td align="center">Spherical</td>
+ <td align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>-908.303</td>
+ <td>-812.347</td>
+ <td>-792.391</td>
+ <td>-783.897</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>257.69</td>
+ <td>279.905</td>
+ <td>284.76</td>
+ <td>293.146</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>0.554</td>
+ <td>2.530</td>
+ <td>2.229</td>
+ <td>2.054</td>
+ </tr>
+ <tr>
+ <td align="left">Variance [mm<sup>2</sup>]</td>
+ <td>28891.6</td>
+ <td>23983</td>
+ <td>22586.9</td>
+ <td>22209.2</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>169.975</td>
+ <td>154.865</td>
+ <td>150.289</td>
+ <td>149.028</td>
+ </tr>
+ <caption>
+ <b>Tab. 5:</b> Cross validation of small region <br>with horizontal range of 15000 m and vertical range of 1200 m<br>
+ with different settings of theoretical variogram
+ </caption>
+</table>
+
+<p>
+<b>The results</b> were compared just using cross sections because of the distribution of the points. The column <i>RST</i>
+ in following tables summarize statistical characteristics of the cross section by <i><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></i>. Other columns represent
+ statistical characteristics of the cross section <i>values</i> and of the <i>differences</i> (between RST and kriging cross sections)
+ produced by each type of variogram.
+
+ <p>
+<table border="1" style="text-align: right;">
+ <tr>
+ <td rowspan="2"></td>
+ <td rowspan="2" align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td colspan="2" align="center">Linear</td>
+ <td colspan="2" align="center">Exponential</td>
+ <td colspan="2" align="center">Spherical</td>
+ <td colspan="2" align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ </tr>
+ <tr>
+ <td># of cells</td>
+ <td>196105</td>
+ <td colspan="2" align="center">196105</td>
+ <td colspan="2" align="center">196105</td>
+ <td colspan="2" align="center">196105</td>
+ <td colspan="2" align="center">196105</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>491.985</td>
+ <td>551.835</td>
+ <td>-643.783</td>
+ <td>543.503</td>
+ <td>-603.59</td>
+ <td>536.309</td>
+ <td>-629.652</td>
+ <td>550.935</td>
+ <td>-622.887</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>1563.660</td>
+ <td>1580.700</td>
+ <td>317.011</td>
+ <td>1572.000</td>
+ <td>316.938</td>
+ <td>1578.820</td>
+ <td>320.219</td>
+ <td>1548.51</td>
+ <td>356.881</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>722.036</td>
+ <td>744.689</td>
+ <td>-22.657</td>
+ <td>740.308</td>
+ <td>-18.271</td>
+ <td>740.968</td>
+ <td>-18.932</td>
+ <td>747.655</td>
+ <td>-25.6238</td>
+ </tr>
+ <tr>
+ <td align="left">Variance mm<sup>2</sup></td>
+ <td>14472.9</td>
+ <td>29200.5</td>
+ <td>7978.76</td>
+ <td>28614.7</td>
+ <td>6978.35</td>
+ <td>29263.9</td>
+ <td>7338.56</td>
+ <td>31396.1</td>
+ <td>9139.46</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>120.303</td>
+ <td>170.882</td>
+ <td>89.324</td>
+ <td>169.159</td>
+ <td>83.5365</td>
+ <td>171.067</td>
+ <td>85.665</td>
+ <td>177.189</td>
+ <td>95.601</td>
+ </tr>
+ <caption>
+ <b>Tab. 6:</b> Statistical characteristics of the results for the whole region<br>with horizontal range of 100 000 m and vertical range of 1 600 m
+ </caption>
+</table>
+
+<p>
+<table>
+ <tr>
+ <td>left: linear variogram; right: exponential variogram</td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/v_kriging_result_linear.png" alt="res_lin" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_result_exponential.png" alt="res_exp" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 6:</b> Interpolated rasters in the whole region
+ </caption>
+</table>
+<table>
+ <tr>
+ <td>left: spherical variogram; right: Gaussian variogram</td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/v_kriging_result_spherical.png" alt="res_spher" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_result_gauss.png" alt="res_gauss" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+</table>
+
+ <p>
+<table border="1" style="text-align: right;">
+ <tr>
+ <td rowspan="2"></td>
+ <td rowspan="2" align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td colspan="2" align="center">Linear</td>
+ <td colspan="2" align="center" style="color: greenyellow;">Exponential</td>
+ <td colspan="2" align="center">Spherical</td>
+ <td colspan="2" align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ </tr>
+ <tr>
+ <td># of cells</td>
+ <td>37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>600.922</td>
+ <td>580.245</td>
+ <td>-669.397</td>
+ <td>595.692</td>
+ <td>-513.497</td>
+ <td>591.531</td>
+ <td>-639.105</td>
+ <td>608.913</td>
+ <td>-378.109</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>1675.090</td>
+ <td>1916.93</td>
+ <td>203.666</td>
+ <td>1837.18</td>
+ <td>172.858</td>
+ <td>1936.17</td>
+ <td>217.189</td>
+ <td>1545.81</td>
+ <td>244.875</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>883.909</td>
+ <td>893.167</td>
+ <td>-9.258</td>
+ <td>869.083</td>
+ <td>14.826</td>
+ <td>863.901</td>
+ <td>20.0083</td>
+ <td>871.364</td>
+ <td>12.5451</td>
+ </tr>
+ <tr>
+ <td align="left">Variance mm<sup>2</sup></td>
+ <td>11102</td>
+ <td>39059.1</td>
+ <td>11442.7</td>
+ <td>22743.8</td>
+ <td>3941.73</td>
+ <td>26359.9</td>
+ <td>5983.39</td>
+ <td>20350.4</td>
+ <td>3796.5</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>105.366</td>
+ <td>197.634</td>
+ <td>106.97</td>
+ <td>150.811</td>
+ <td>62.7832</td>
+ <td>162.357</td>
+ <td>77.352</td>
+ <td>142.655</td>
+ <td>61.616</td>
+ </tr>
+ <caption>
+ <b>Tab. 7:</b> Statistical characteristics of the results for the small region<br>with horizontal range of 20 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<p>
+<table border="1" style="text-align: right;">
+ <tr>
+ <td rowspan="2"></td>
+ <td rowspan="2" align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td colspan="2" align="center" style="color: greenyellow;">Linear</td>
+ <td colspan="2" align="center">Exponential</td>
+ <td colspan="2" align="center">Spherical</td>
+ <td colspan="2" align="center" style="color: greenyellow;">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ </tr>
+ <tr>
+ <td># of cells</td>
+ <td>37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>600.922</td>
+ <td>576.625</td>
+ <td>-709.196</td>
+ <td>595.284</td>
+ <td>-580.65</td>
+ <td>594.467</td>
+ <td>-665.563</td>
+ <td>556.744</td>
+ <td>-937.124</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>1675.090</td>
+ <td>1920.29</td>
+ <td>217.844</td>
+ <td>1847.160</td>
+ <td>199.350</td>
+ <td>1925.91</td>
+ <td>209.544</td>
+ <td>2218.170</td>
+ <td>249.345</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>883.909</td>
+ <td>886.734</td>
+ <td>-2.82485</td>
+ <td>865.272</td>
+ <td>18.6376</td>
+ <td>860.772</td>
+ <td>23.137</td>
+ <td>860.294</td>
+ <td>23.615</td>
+ </tr>
+ <tr>
+ <td align="left">Variance mm<sup>2</sup></td>
+ <td>11102</td>
+ <td>37500.3</td>
+ <td>10985.4</td>
+ <td>23111.1</td>
+ <td>4697.95</td>
+ <td>25530.4</td>
+ <td>6226.34</td>
+ <td>32575</td>
+ <td>10525.7</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>105.366</td>
+ <td>193.65</td>
+ <td>104.811</td>
+ <td>152.023</td>
+ <td>68.5416</td>
+ <td>159.782</td>
+ <td>78.907</td>
+ <td>180.485</td>
+ <td>102.595</td>
+ </tr>
+ <caption>
+ <b>Tab. 8:</b> Statistical characteristics of the results for the small region<br>with horizontal range of 15 000 m and vertical range of 1 200 m
+ </caption>
+</table>
+
+<p>
+<table border="1" style="text-align: right;">
+ <tr>
+ <td rowspan="2"></td>
+ <td rowspan="2" align="center"><a href="http://grass.osgeo.org/grass64/manuals/v.vol.rst.html" target="_blank">v.vol.rst</a></td>
+ <td colspan="2" align="center">Exponential</td>
+ <td colspan="2" align="center">Spherical</td>
+ <td colspan="2" align="center">Gaussian</td>
+ </tr>
+ <tr>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ <td align="center">Value</td>
+ <td align="center">Diff.</td>
+ </tr>
+ <tr>
+ <td># of cells</td>
+ <td>37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ <td colspan="2" align="center">37639</td>
+ </tr>
+ <tr>
+ <td align="left">Minimum [mm]</td>
+ <td>600.922</td>
+ <td>618.417</td>
+ <td>-453.562</td>
+ <td>600.733</td>
+ <td>-665.563</td>
+ <td>608.602</td>
+ <td>-415.753</td>
+ </tr>
+ <tr>
+ <td align="left">Maximum [mm]</td>
+ <td>1675.090</td>
+ <td>1687.83</td>
+ <td>177.512</td>
+ <td>1586.71</td>
+ <td>209.544</td>
+ <td>1571.55</td>
+ <td>238.521</td>
+ </tr>
+ <tr>
+ <td align="left">Mean [mm]</td>
+ <td>883.909</td>
+ <td>867.071</td>
+ <td>16.8376</td>
+ <td>867.047</td>
+ <td>23.137</td>
+ <td>867.075</td>
+ <td>16.834</td>
+ </tr>
+ <tr>
+ <td align="left">Variance mm<sup>2</sup></td>
+ <td>11102</td>
+ <td>18570.3</td>
+ <td>3191.89</td>
+ <td>19377.5</td>
+ <td>6226.34</td>
+ <td>19744.4</td>
+ <td>4155.31</td>
+ </tr>
+ <tr>
+ <td align="left">Std. deviation [mm]</td>
+ <td>105.366</td>
+ <td>136.273</td>
+ <td>41.737</td>
+ <td>139.203</td>
+ <td>78.907</td>
+ <td>140.515</td>
+ <td>64.462</td>
+ </tr>
+ <caption>
+ <b>Tab. 9:</b> Statistical characteristics of the results for the small region<br>with horizontal range of 15 000 m and vertical range of 1 200 m<br>with different settings of the theoretical variogram
+ </caption>
+</table>
+
+<p>
+<table>
+ <tr>
+ <td> Gaussian variogram from <b>Tab. 4</b> vs. Exponential variogram from <b>Tab. 5</b></td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_result_gauss_1.png" alt="res_gauss_1" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_result_exponential_2.png" alt="res_exponential_2" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 7:</b> Interpolated rasters with the best (on the left) and the worse (on the right) cross validation results.
+ </caption>
+</table>
+<table>
+ <tr>
+ <td> Linear variogram from <b>Tab. 4</b> vs. Spherical variogram from <b>Tab. 5</b></td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_result_linear_1.png" alt="res_linear_1" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_result_spherical_2.png" alt="res_spherical_2" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+</table>
+<table>
+ <tr>
+ <td> Exponential variogram from <b>Tab. 3</b> vs. Gaussian variogram from <b>Tab. 5</b></td>
+ </tr>
+ <tr>
+ <td>
+ <img src="images/small/v_kriging_result_exponential.png" alt="res_exponential" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/small/v_kriging_result_gauss_2.png" alt="res_gauss_2" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+</table>
+
+<p>
+More case studies on 3D data are described in (<i>Stopkova, 2014</i>).
+
+<h3>2D kriging</h3>
+Input layer should contain 2D coordinates (xy) and values to be interpolated (in attribute table). The commands can in general look like this:
+<div class="code"><pre>
+v.kriging phase=initial in=input_layer icol=name report=report_file.txt file=png -2
+</pre></div>
+<div class="code"><pre>
+v.kriging in=input_layer phase=final final_function=linear icol=name file=png \
+ out=name crossval=crossval_file.txt -2
+</pre></div>
+
+<h4>Case study: elev_lid792_randpts</h4>
+<p>
+The case study is based on 500 random points that were extracted from input points of Digital Elevation Model (DEM)
+<i>elev_lid792_randpts</i> from the North Carolina
+<a href="http://grass.osgeo.org/download/sample-data/" target="_blank">dataset</a>.
+
+<p>In initial phase, temporary <b>experimental variogram</b> was computed:
+<div class="code"><pre>
+v.kriging phase=initial in=elev_lid792_selected ic=value azimuth=45. td=45. \
+report=lid792_500_linear.txt -2 --o
+</pre></div>
+
+Then, in final phase (middle phase is skipped in 2D kriging) the <b>theoretical variogram</b> was computed and
+interpolation of unknown values was performed:
+
+<div class="code"><pre>
+v.kriging in=elev_lid792_selected phase=final final_function=linear ic=value \
+file=png out=lid792_500_linear crossval=lid792_500_xval_linear.txt -2 --o
+</pre></div>
+Variogram modelling was compared with the result of variogram analysis in <i>Surfer </i> (<i>Golden Software, Inc.</i>).
+
+<p>
+<table>
+ <tr>
+ <td>
+ <img src="images/v_kriging_variogram_lid792_500_linear.png" alt="variogram_500_linear" style="float: left; width: 50%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_variogram_lid792_500_surfer.png" alt="variogram_500_surfer" style="float: left; width: 35%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <caption>
+ <b>Fig. 8:</b> Experimental and theoretical variogram (left: by <i>v.kriging</i>; right: by <i>Surfer</i> (<i>Golden Software, Inc.</i>))
+ </caption>
+</table>
+The difference in coefficient of the linear function might be caused by using slightly different lag size or by different approach to the computation (spatial index in <i>v.kriging</i>, optimization algorithms in <i>Surfer</i> (<i>Golden Software, Inc.</i>) etc.).
+
+<p><b>The results</b> were compared with the values interpolated using the module <i><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></i> and kriging tool of <i>Surfer</i> (<i>Golden Software, Inc.</i>). <b>Fig. 9a</b> - <b>9c</b> show interpolated DEM and the comparisons with the results of another interpolation tools. Statistical characteristics of the results are summarized in <b>Tab. 10</b>.
+<p>
+<table>
+ <tr>
+ <td>
+ <img src="images/v_kriging_result_lid792_500.png" alt="elev_kriging" style="float: left; width: 30%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_diff_lid792_500_rst.png" alt="elev_diff_rst" style="float: left; width: 30%; margin-right: 1%; margin-bottom: 0.5em;">
+ <img src="images/v_kriging_diff_lid792_500_surfer.png" alt="elev_diff_surfer" style="float: left; width: 30%; margin-right: 1%; margin-bottom: 0.5em;">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Fig. 9:</b> <b>a</b> - the DEM interpolated using <i>v.kriging</i>, <b>b</b> - the difference between <i>v.kriging</i> and <i><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></i>, <b>c</b> - the difference between <i>v.kriging</i> and <i>Surfer</i> (<i>Golden Software, Inc.</i>))
+ </td>
+ </tr>
+</table>
+
+<br>
+
+<table border="1" style="text-align: right; margin-left: 70px;">
+ <tr>
+ <td rowspan="2" style="text-align: center;"><b>Results</b></td>
+ <td rowspan="2" style="text-align: center;">v.kriging</td>
+ <td colspan="2" style="text-align: center;"><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></td>
+ <td colspan="2" style="text-align: center;">Surfer (<i>Golden Software, Inc.</i>)</td>
+ </tr>
+ <tr>
+ <td>Values</td>
+ <td>Differences</td>
+ <td>Values</td>
+ <td>Differences</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Minimum [m]</td>
+ <td>105.114</td>
+ <td>105.061</td>
+ <td>-1.065</td>
+ <td>105.090</td>
+ <td>-1.181</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Maximum [m]</td>
+ <td>131.510</td>
+ <td>131.570</td>
+ <td>2.072</td>
+ <td>131.510</td>
+ <td>0.522</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Mean [m]</td>
+ <td>120.763</td>
+ <td>120.781</td>
+ <td>0.018</td>
+ <td>120.584</td>
+ <td>-0.178</td>
+ </tr>
+<tr>
+ <td style="text-align: left;">Variance [m<sup>2</sup>]</td>
+ <td>43.7367</td>
+ <td>43.2701</td>
+ <td>0.045581</td>
+ <td>44.2389</td>
+ <td>0.027244</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Standard deviation [m]</td>
+ <td>6.613</td>
+ <td>6.578</td>
+ <td>0.165</td>
+ <td>6.651</td>
+ <td>0.213</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">95% quantile [m]</td>
+ <td>130.115</td>
+ <td>130.109</td>
+ <td>0.225</td>
+ <td>130.088</td>
+ <td>0.213</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">75% quantile [m]</td>
+ <td>126.580</td>
+ <td>126.587</td>
+ <td>0.046</td>
+ <td>126.434</td>
+ <td>-0.047</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">50% quantile [m]</td>
+ <td>121.315</td>
+ <td>121.325</td>
+ <td>0.000</td>
+ <td>121.080</td>
+ <td>-0.190</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">25% quantile [m]</td>
+ <td>115.749</td>
+ <td>115.786</td>
+ <td>-0.047</td>
+ <td>115.489</td>
+ <td>-0.328</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">5% quantile [m]</td>
+ <td>109.004</td>
+ <td>109.115</td>
+ <td>-0.139</td>
+ <td>108.800</td>
+ <td>-0.487</td>
+ </tr>
+ <caption>
+ <b>Tab. 10:</b> Comparison of statistical characteristics of interpolated rasters
+ </caption>
+</table>
+
+<br>
+
+Also <b>cross validation</b> results of all the methods mentioned above and their statistical characteristics have been compared. Cross validation using <i><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></i> was performed with these settings:
+<div class="code"><pre>
+v.surf.rst -c input="elev_lid792_selected at test_kriging" layer="1" zcolumn="value" \
+cvdev="lid792_500_rst_xval" tension=40 segmax=30 npmin=120 dmin=5.000000 dmax=25.000000 zscale=1.0
+</pre></div>
+
+Cross validation points are shown in <b>Fig. 10</b> (bigger circles represent kriging results, smaller circles represent the results of RST). Statistical characteristics of the cross validation are summarized in <b>Tab. 11</b>.
+
+<br>
+
+<table style="float: left; align: left;">
+ <tr>
+ <td rowspan="11">
+ <img src="images/v_kriging_xval_rst_krig.png" alt="xval" style="margin-right: 10%; margin-left: 10%;">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <b>Fig. 10:</b> Cross validation by <i>v.kriging</i> and <i><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></i>
+ </td>
+ </tr>
+</table>
+<table border="1" style="text-align: right; float: left; align: left; vertical-align: center;">
+ <tr>
+ <td style="text-align: center;"><b>Cross validation</b></td>
+ <td>v.kriging</td>
+ <td><a href="http://grass.osgeo.org/grass64/manuals/v.surf.rst.html" target="blank">v.surf.rst</a></td>
+ <td>Surfer (<i>Golden Software, Inc.</i>)</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Minimum [m]</td>
+ <td>-2.990</td>
+ <td>-1.593</td>
+ <td>-2.344</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Maximum [m]</td>
+ <td>2.399</td>
+ <td>3.362</td>
+ <td>3.011</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Mean [m]</td>
+ <td>-0.004</td>
+ <td>0.004</td>
+ <td>0.003</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Variance [m<sup>2</sup>]</td>
+ <td>0.132490</td>
+ <td>0.143742</td>
+ <td>0.133809</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">Standard deviation [m]</td>
+ <td>0.364</td>
+ <td>0.379</td>
+ <td>0.366</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">95% quantile [m]</td>
+ <td>0.434</td>
+ <td>0.557</td>
+ <td>0.584</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">50% quantile [m]</td>
+ <td>0.018</td>
+ <td>-0.013</td>
+ <td>-0.020</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">25% quantile [m]</td>
+ <td>-0.113</td>
+ <td>-0.144</td>
+ <td>-0.126</td>
+ </tr>
+ <tr>
+ <td style="text-align: left;">5% quantile [m]</td>
+ <td>-0.587</td>
+ <td>-0.499</td>
+ <td>-0.445</td>
+ </tr>
+ <caption>
+ <b>Tab. 11:</b> Statistical characteristics<br>of the cross validation results
+ </caption>
+</table>
+ <p>
+
+ <br style="clear:both">
+ <p>
+ <b>Recommendations</b>
+ <table>
+ <tr>
+ <td>
+ In case of too much <b>warnings</b> about input points that have
+ "<b>less than 2 neighbours in its closest surrounding</b>. The perimeter of the surrounding will be increased...", please
+ consider shorter variogram range.
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Save just figures with theoretical variogram (using <i>file=extension</i> in the middle and final phase).
+ Experimental variograms are included in the theoretical variogram plot and separate "experimental" plots
+ can be just temporal.
+ </td>
+ </tr>
+ </table>
+
+ <p>
+ <b>References</b>
+ <table>
+ <tr>
+ <td>
+ Neteler, M. and Mitasova, H. (2004). <i>Open Source GIS: A GRASS GIS Approach</i>.
+ 2nd Ed. 401 pp, Springer, New York. Online Supplement: http://www.grassbook.org
+ </td>
+ </tr>
+ <tr>
+ <td>
+ Stopkova, E. (2014). <i>Development and application of 3D analytical functions in spatial analyses</i>
+ (Unpublished doctoral dissertation). The Department of Theoretical Geodesy, Faculty of Civil Engineering
+ of Slovak University of Technology in Bratislava, Slovakia.
+ </td>
+ </tr>
+ </table>
+
<h2>TODO</h2>
<ul>
+<li>still need <b>optimization</b> for large datasets</li>
<li><b>anisotropy</b> in horizontal direction missing
<li>current version is suitable just for <b>metric coordinate systems</b>
<li>enable <b>mask usage</b>
@@ -30,7 +1115,6 @@
<h2>BUGS</h2>
<ul>
-<li>2D variogram gives quite inaccurate results for <b>sparse (or spatially heterogeneous) data</b>
<li><b>bivariate variogram</b> - too inaccurate results
</ul>
More information about the grass-commit
mailing list