[GRASS-SVN] r32957 - grass/branches/develbranch_6/vector/v.surf.idw
svn_grass at osgeo.org
svn_grass at osgeo.org
Thu Aug 21 05:05:13 EDT 2008
Author: benducke
Date: 2008-08-21 05:05:13 -0400 (Thu, 21 Aug 2008)
New Revision: 32957
Modified:
grass/branches/develbranch_6/vector/v.surf.idw/description.html
grass/branches/develbranch_6/vector/v.surf.idw/main.c
Log:
This update adds support for the "power parameter" to v.surf.idw.
That parameter is a standard part of the IDW algorithm and describes the
fall-off in weight of a data point with spatial distance from the cell to be
interpolated.
Modified: grass/branches/develbranch_6/vector/v.surf.idw/description.html
===================================================================
--- grass/branches/develbranch_6/vector/v.surf.idw/description.html 2008-08-21 09:03:44 UTC (rev 32956)
+++ grass/branches/develbranch_6/vector/v.surf.idw/description.html 2008-08-21 09:05:13 UTC (rev 32957)
@@ -47,6 +47,14 @@
sites closest to the centre of the cell will be interpolated).</p>
<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>
+
+<P>
By setting <EM>npoints=1</EM>, the module can be used
to calculate raster Voronoi diagrams (Thiessen polygons).</p>
Modified: grass/branches/develbranch_6/vector/v.surf.idw/main.c
===================================================================
--- grass/branches/develbranch_6/vector/v.surf.idw/main.c 2008-08-21 09:03:44 UTC (rev 32956)
+++ grass/branches/develbranch_6/vector/v.surf.idw/main.c 2008-08-21 09:05:13 UTC (rev 32957)
@@ -64,9 +64,10 @@
double dist;
double sum1, sum2, interp_value;
int n, field;
+ double p;
struct
{
- struct Option *input, *npoints, *output, *dfield, *col;
+ struct Option *input, *npoints, *power, *output, *dfield, *col;
} parm;
struct cell_list
{
@@ -97,6 +98,13 @@
parm.npoints->description = _("Number of interpolation points");
parm.npoints->answer = "12";
+ parm.power = G_define_option();
+ parm.power->key = "power";
+ parm.power->type = TYPE_DOUBLE;
+ parm.power->answer = "2.0";
+ parm.power->description =
+ _("Power parameter; greater values assign greater influence to closer points");
+
parm.dfield = G_define_standard_option(G_OPT_V_FIELD);
parm.dfield->description =
_("If set to 0, z coordinates are used (3D vector only)");
@@ -135,8 +143,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);
@@ -375,8 +384,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
More information about the grass-commit
mailing list