From 7aa0dd50f233a5f800ab81e871ac702dac70a7b1 Mon Sep 17 00:00:00 2001 From: nyalldawson Date: Wed, 8 May 2013 12:53:58 +1000 Subject: [PATCH] Small fixes to heatmap plugin Update context help for heatmap --- resources/context_help/HeatmapGui-en_US | 44 ++++++++++++++++++------- src/plugins/heatmap/heatmap.cpp | 14 ++++++-- src/plugins/heatmap/heatmapguibase.ui | 4 +-- 3 files changed, 45 insertions(+), 17 deletions(-) diff --git a/resources/context_help/HeatmapGui-en_US b/resources/context_help/HeatmapGui-en_US index ea6c96fd842c..ef2e10fdbfb3 100644 --- a/resources/context_help/HeatmapGui-en_US +++ b/resources/context_help/HeatmapGui-en_US @@ -1,32 +1,52 @@

Heatmap Plugin Help

-

The Heatmap plugin uses Kernel Density Estimation to create a density (heatmap) raster of an input point vector layer. The density is calculated based on the number of points in a location, with larger numbers of clustered points resulting in a larger raster values.

+

The Heatmap plugin uses Kernel Density Estimation to create a density (heatmap) +raster of an input point vector layer. The density is calculated based on the +number of points in a location, with larger numbers of clustered points resulting +in larger values. Heatmaps allow easy identification of "hotspots" and +clustering of points.

Dialog Parameters

-

Input Point Vector

+

Input point layer

The input is always a vector layer of point type. All the point vector layers that are currently loaded in the canvas are shown in the drop-down list. Click the dropdown button and select the desired layer.

-

Output Raster

+

Output raster

The output raster location and filename can be set by clicking the button next to the output raster textbox.
Note: The file format is automatically added depending upon the output format selected, if not explicitly given.

-

Output Format

+

Output format

All the file creation supporting GDAL formats are available in the drop down list. Click and select the required output format for your file.
-Note: GeoTiff and ERDAS Imagine .img formats are recommended. Some formats make the application crash. Kindly stick to the recommended formats until the crash issue is resolved or use an other formats if you know GDAL supports it completely.

+Note: GeoTiff and ERDAS Imagine .img formats are recommended. Some formats make the application crash. Kindly stick to the recommended formats until the crash issue is resolved or use other formats if you know GDAL supports it completely.

-

Heatmap Point Attributes

-

Radius (bandwidth)

-

The buffer radius specifies the distance around a point at which the influence of the point will be felt. Larger values result in greater smoothing, but smaller values may show finer details.

+

Radius (bandwidth)

+

Used to specify the heatmap search radius (or kernel bandwidth) in meters or map units. The radius specifies the distance around a point at which the influence + of the point will be felt. Larger values result in greater smoothing, but smaller values may show finer details and variation in point density.

+

Advanced Options

+ +

Rows and Columns

+

Used to change the dimensions of the output raster file. These values are also linked to the Cell size X and Cell size Y values. +Increasing the number of rows or colums will decrease the cell size and increase the file size of the output file. The values in Rows and Columns +are also linked, so doubling the number of rows will automatically double the number of columns and the cell sizes will also be halved. The geographical area of the output raster will remain the same!

+ +

Cell size X and Y

+

Control the geographic size of each pixel in the output raster. Changing these values will also change the number of Rows and Columns in the output + raster.

+

Kernel shape

-

The kernel shape parameter controls the rate at which the influence of a point decreases as the distance from the point increases. A number of standard kernel functions are available, which are described in detail on Wikipedia. -

+

The kernel shape controls the rate at which the influence of a point decreases as the distance from the point increases. Different kernels decay at +different rates, so a triweight kernel gives features greater weight for distances closer to the point then the Epanechnikov kernel does. Consequently, +triweight results in "sharper" hotspots, and Epanechnikov results in "smoother" hotspots. A number of standard kernel functions are available in QGIS, +which are described and illustrated on Wikipedia.

+ +

Decay ratio

+

For triangular kernels, the decay ratio defines amount of influence that applies to the outermost pixels in the buffer radius. A value of 0 reflects a standard triangular kernel, where the influences drops to zero as the distance from the pixel to the point approaches the specified radius. In contrast, a value of 1 indicates that no falloff occurs as the distance from the point increases.

+

Use radius from field

Optionally, the value in a specified field can be used to control the kernel radius for each point in the input layer.

+

Use weight from field

Optionally, a attribute containing weights for points can be used to weight some points in the input layer more than others.

-

Decay ratio

-

For triangular kernels, the decay ratio defines amount of influence that applies to the outermost pixels in the buffer radius. A value of 0 reflects a standard triangular kernel, where the influences drops to zero as the distance from the pixel to the point approaches the specified radius. In contrast, a value of 1 indicates that no falloff occurs as the distance from the point increases.

Further Details

Contact the author through aruntheguy at gmail dot com

diff --git a/src/plugins/heatmap/heatmap.cpp b/src/plugins/heatmap/heatmap.cpp index 3777e60d18ad..3f5f22456d43 100644 --- a/src/plugins/heatmap/heatmap.cpp +++ b/src/plugins/heatmap/heatmap.cpp @@ -412,10 +412,18 @@ double Heatmap::triangularKernel( double distance, int bandwidth ) // Normalizing constant. In this case it's calculated a little different // due to the inclusion of the non-standard "decay" parameter - double k = 3. / (( 1. + 2. * mDecay ) * M_PI * pow(( double )bandwidth, 2 ) ); + if ( mDecay >= 0 ) + { + double k = 3. / (( 1. + 2. * mDecay ) * M_PI * pow(( double )bandwidth, 2 ) ); - // Derived from Wand and Jones (1995), p. 175 (with addition of decay parameter) - return k * ( 1. - ( 1. - mDecay ) * ( distance / ( double )bandwidth ) ); + // Derived from Wand and Jones (1995), p. 175 (with addition of decay parameter) + return k * ( 1. - ( 1. - mDecay ) * ( distance / ( double )bandwidth ) ); + } + else + { + // Non-standard or mathematically valid negative decay ("coolmap") + return ( 1. - ( 1. - mDecay ) * ( distance / ( double )bandwidth ) ); + } } // Unload the plugin by cleaning up the GUI diff --git a/src/plugins/heatmap/heatmapguibase.ui b/src/plugins/heatmap/heatmapguibase.ui index f9bc3dc546eb..c82b5111269a 100644 --- a/src/plugins/heatmap/heatmapguibase.ui +++ b/src/plugins/heatmap/heatmapguibase.ui @@ -127,7 +127,7 @@ - Row + Rows rowLineEdit @@ -147,7 +147,7 @@ - Column + Columns columnLineEdit