User Tools

Site Tools


api:dk11:delphi:gisinterpolation.tgis_gaussianheatmap

TGIS_GaussianHeatmap class

DK11 for Delphi | GisInterpolation.TGIS_GaussianHeatmap | Classes | Constructors | Methods | Properties

Fast heatmap generator, creates superposition of normal (Gaussian) distribution for each data point.

Available also on: .NET | Java | ActiveX | Python.

Syntax

// Delphi
type
  TGIS_GaussianHeatmap = class( TGIS_VectorToGridAbstract )
  end;
// C++ Builder
class PASCALIMPLEMENTATION TGIS_GaussianHeatmap : public TGIS_VectorToGridAbstract
{
};

Inheritance

Constructors

Inherited Overrides Protected
Name Visibility Description
Create public

Methods

Inherited Overrides Protected
Name Visibility Description
EstimateRadius public Calculates a "good choice" of the 3-sigma ("radius") of the Gaussian distribution.
Generate public Populates a pixel (grid) layer with values resulting from computations based on the set of sample points from the vector layer.
(Overrides TGIS_VectorToGridAbstract.Generate)

Properties

Inherited Protected
Name Visibility Description
Coordinate public Defines which coordinate is taken as interpolation value if the interpolation is not based on an attribute field; default is Z.
(Inherited from TGIS_VectorToGridAbstract)
DefaultValue public If UseDefaultValue is true, then this value will be set for each grid cell for which the interpolated value cannot be computed.
(Inherited from TGIS_VectorToGridAbstract)
Radius public 3-sigma ("radius") of the Gaussian distribution.
UseDefaultValue public If true, then each grid cell for which the interpolated value cannot be computed will be set to DefaultValue.
(Inherited from TGIS_VectorToGridAbstract)

Remarks

Method

The heat map is a method of visual presentation of spatial point data values and concentration. Mathematically it is a sum of normal (Gaussian) distributions located at each sample point with peak values representing values associated with each point.

Usage

There are three different scenarios for generating a heat map:

  1. heat map based on a Z, M, or Z+M coordinate value:
    • set the Coordinate property to the desired option
    • pass an empty string as the field name to the Generate method
  2. heat map based on a attribute field value:
    • pass the field name to the Generate method
    • with the above, the Coordinate property is neglected
  3. concentration map which means that each point has the same weight (value equal to 1.0):
    • set the Coordinate property to None
    • pass an empty string as the field name to the Generate method

The resulting grid values are normalized (linearly rescaled) so they do not exceed the values of the source data (minimum and maximum grid values are the same as the minimum and maximum source values).

The resulting heatmap is highly dependent on the Radius parameter (3-sigma of the normal distribution). To easily set a reasonable value of Radius, call the EstimateRadius method before Generate. The Radius value set by the EstimateRadius method is the average of the minimal distance between neighboring points, multiplied by 3.

Pros

A quick and great looking way to present quantitative data for easy, visual analysis.

Cons

This is neither an interpolation nor an approximation method! It is suitable only for specific kinds of analysis (like a distribution of frequency of events).

Example

Delphi

var
  src : TGIS_LayerVector ;
  dst : TGIS_LayerPixel ;
  vtg : TGIS_GaussianHeatmap ;  
  ext : TGIS_Extent ; 
begin
  // get the source layer (GIS is TGIS_ViewerWnd)
  src := TGIS_LayerVector( GIS.Get( 'points' ) ) ;
  ext := src.Extent ;
 
  // create the destination layer (grid, 200x200 pixels)
  dst := TGIS_LayerPixel.Create ;
  dst.Build( True, lsrc.CS, ext, 200, 200 ) ;
  dst.Name := 'Heatmap' ;
  dst.Params.Pixel.GridShadow := False ;
 
  // create a heatmap generator
  vtg:= TGIS_GaussianHeatmap.Create ;
  try
    // attach event to track the progress
    vtg.BusyEvent := doBusyEvent ;
 
    // set reasonable value of Radius
    vtg.EstimateRadius( src, src.Extent, dst ) ;                   
 
    // initiate the grid generation process for the
    // POPULATION attribute field
    vtg.Import( src, ext, 'POPULATION', dst, ext ) ;
  finally
    vtg.Free ;
  end ;  
 
  // add the grid to the viewer
  GIS.Add( dst ) ;
 
  // update the viewer
  GIS.FullExtent ;
end ;

References

2024/12/20 22:18

Page Tools