[GRASS-SVN] r59107 - grass/trunk/vector/v.surf.idw
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Feb 20 11:36:40 PST 2014
Author: annakrat
Date: 2014-02-20 11:36:40 -0800 (Thu, 20 Feb 2014)
New Revision: 59107
Modified:
grass/trunk/vector/v.surf.idw/main.c
grass/trunk/vector/v.surf.idw/v.surf.idw.html
Log:
v.surf.idw: added missing power parameter from develbranch
Modified: grass/trunk/vector/v.surf.idw/main.c
===================================================================
--- grass/trunk/vector/v.surf.idw/main.c 2014-02-20 14:39:50 UTC (rev 59106)
+++ grass/trunk/vector/v.surf.idw/main.c 2014-02-20 19:36:40 UTC (rev 59107)
@@ -62,9 +62,10 @@
double dist;
double sum1, sum2, interp_value;
int n;
+ double p;
struct
{
- struct Option *input, *npoints, *output, *dfield, *col;
+ struct Option *input, *npoints, *power, *output, *dfield, *col;
} parm;
struct
{
@@ -110,6 +111,15 @@
parm.npoints->answer = "12";
parm.npoints->guisection = _("Settings");
+ parm.power = G_define_option();
+ parm.power->key = "power";
+ parm.power->type = TYPE_DOUBLE;
+ parm.power->answer = "2.0";
+ parm.power->label = _("Power parameter");
+ parm.power->description =
+ _("Greater values assign greater influence to closer points");
+ parm.power->guisection = _("Settings");
+
flag.noindex = G_define_flag();
flag.noindex->key = 'n';
flag.noindex->label = _("Don't index points by raster cell");
@@ -137,7 +147,9 @@
list =
(struct list_Point *) G_calloc((size_t) search_points,
sizeof(struct list_Point));
-
+
+ p = atof(parm.power->answer);
+
/* get the window, dimension arrays */
G_get_window(&window);
@@ -373,8 +385,8 @@
sum2 = 0.0;
for (n = 0; n < nsearch; n++) {
if ((dist = list[n].dist)) {
- sum1 += list[n].z / dist;
- sum2 += 1.0 / dist;
+ sum1 += list[n].z / pow(dist, p);
+ sum2 += 1.0 / pow(dist, p);
}
else {
/* If one site is dead on the centre of the cell, ignore
Modified: grass/trunk/vector/v.surf.idw/v.surf.idw.html
===================================================================
--- grass/trunk/vector/v.surf.idw/v.surf.idw.html 2014-02-20 14:39:50 UTC (rev 59106)
+++ grass/trunk/vector/v.surf.idw/v.surf.idw.html 2014-02-20 19:36:40 UTC (rev 59107)
@@ -45,7 +45,16 @@
the -n flag is specified, in which case only the <em>count</em>
points closest to the centre of the cell will be interpolated).
-<p>By setting <em>npoints=1</em>, the module can be used
+<p>
+The <em>power</em> parameter defines an exponential distance weight.
+Greater values assign greater influence to values closer to the
+point to be interpolated. The interpolation function peaks sharply over
+the given data points for 0 < <em>p</em> < 1 and more smoothly for
+larger values. The default value for the power parameter is 2.
+
+
+<p>
+By setting <em>npoints=1</em>, the module can be used
to calculate raster Voronoi diagrams (Thiessen polygons).
More information about the grass-commit
mailing list