[GRASS-SVN] r54271 - grass/trunk/vector/v.kernel
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Dec 12 13:58:58 PST 2012
Author: mmetz
Date: 2012-12-12 13:58:58 -0800 (Wed, 12 Dec 2012)
New Revision: 54271
Modified:
grass/trunk/vector/v.kernel/function.c
grass/trunk/vector/v.kernel/main.c
grass/trunk/vector/v.kernel/v.kernel.html
Log:
v.kernel: stddeviation -> radius
Modified: grass/trunk/vector/v.kernel/function.c
===================================================================
--- grass/trunk/vector/v.kernel/function.c 2012-12-12 17:11:15 UTC (rev 54270)
+++ grass/trunk/vector/v.kernel/function.c 2012-12-12 21:58:58 UTC (rev 54271)
@@ -103,9 +103,10 @@
/*****************kernel density functions******************************/
-double gaussianKernel2(double term, double bandwidth, double x)
+double gaussianKernel4(double term, double bandwidth, double x)
{
/* term is set by setKernelFunction */
+ /* bandwidth is here SD */
/*
double term =
@@ -114,7 +115,8 @@
x /= bandwidth;
- return (term * exp(-(x * x) / 2.));
+ /* SD = radius (bandwidth) / 4 */
+ return (term * exp((x * x) / -2.));
}
/* Note: these functions support currently only 1D and 2D, consider this for example
@@ -290,7 +292,7 @@
*term *= (35. / 32);
break;
case KERNEL_GAUSSIAN:
- kernelfn = gaussianKernel2;
+ kernelfn = gaussianKernel4;
*term =
1. / (pow(bandwidth, dimension) * pow((2. * M_PI), dimension / 2.));
break;
Modified: grass/trunk/vector/v.kernel/main.c
===================================================================
--- grass/trunk/vector/v.kernel/main.c 2012-12-12 17:11:15 UTC (rev 54270)
+++ grass/trunk/vector/v.kernel/main.c 2012-12-12 21:58:58 UTC (rev 54271)
@@ -75,7 +75,7 @@
int main(int argc, char **argv)
{
struct Option *in_opt, *net_opt, *out_opt;
- struct Option *stddev_opt, *dsize_opt, *segmax_opt, *netmax_opt,
+ struct Option *radius_opt, *dsize_opt, *segmax_opt, *netmax_opt,
*multip_opt, *node_opt, *kernel_opt;
struct Flag *flag_o, *flag_q, *flag_normalize, *flag_multiply;
char *desc;
@@ -125,11 +125,11 @@
out_opt->required = YES;
out_opt->description = _("Output raster/vector map");
- stddev_opt = G_define_option();
- stddev_opt->key = "stddeviation";
- stddev_opt->type = TYPE_DOUBLE;
- stddev_opt->required = YES;
- stddev_opt->description = _("Standard deviation in map units");
+ radius_opt = G_define_option();
+ radius_opt->key = "radius";
+ radius_opt->type = TYPE_DOUBLE;
+ radius_opt->required = YES;
+ radius_opt->description = _("Kernel radius in map units");
dsize_opt = G_define_option();
dsize_opt->key = "dsize";
@@ -206,7 +206,8 @@
exit(EXIT_FAILURE);
/*read options */
- sigma = atof(stddev_opt->answer);
+ dmax = atof(radius_opt->answer);
+ sigma = dmax;
dsize = atof(dsize_opt->answer);
segmax = atof(segmax_opt->answer);
netmax = atof(netmax_opt->answer);
@@ -374,9 +375,8 @@
}
}
- dmax = sigma;
if (kernel_function == KERNEL_GAUSSIAN)
- dmax = sigma * 4.; /* should be sigma /= 4.; */
+ sigma /= 4.;
if (net_opt->answer) {
setKernelFunction(kernel_function, 1, sigma, &term);
Modified: grass/trunk/vector/v.kernel/v.kernel.html
===================================================================
--- grass/trunk/vector/v.kernel/v.kernel.html 2012-12-12 17:11:15 UTC (rev 54270)
+++ grass/trunk/vector/v.kernel/v.kernel.html 2012-12-12 21:58:58 UTC (rev 54271)
@@ -16,7 +16,12 @@
The <em>mult</em> option is needed to overcome the limitation that
the resulting density in case of a vector map output is stored as category
(Integer). The density result stored as category may be multiplied by this number.
-<p>With the <em>-o</em> flag (experimental) the command tries to calculate an
+<p>
+For the <em>gaussian</em> kernel, standard deviation for the
+<a href="http://en.wikipedia.org/wiki/Kernel_(statistics)#Kernel_functions_in_common_use">gaussian function</a>
+is set to 1/4 of the radius.
+<p>
+With the <em>-o</em> flag (experimental) the command tries to calculate an
optimal standard deviation. The value of <em>stddeviation</em> is taken
as maximum value. Standard deviation is calculated using ALL points,
not just those in the current region.
More information about the grass-commit
mailing list