Class HeatmapProcess
- Object
-
- HeatmapProcess
-
- All Implemented Interfaces:
VectorProcess
public class HeatmapProcess extends Object implements VectorProcess
A Process that uses aHeatmapSurface
to compute a heatmap surface over a set of irregular data points as aGridCoverage
. Heatmaps are known more formally as Multivariate Kernel Density Estimation.The appearance of the heatmap is controlled by the kernel radius, which determines the "radius of influence" of input points. The radius is specified by the radiusPixels parameter, which is in output pixels. Using pixels allows easy estimation of a value which will give a visually effective result, and ensures the heatmap appearance changes to match the zoom level.
By default each input point has weight 1. Optionally the weights of points may be supplied by an attribute specified by the
weightAttr
parameter.All geometry types are allowed as input. For non-point geometries the centroid is used.
To improve performance, the surface grid can be computed at a lower resolution than the requested output image using the
pixelsPerCell
parameter. The grid is upsampled to match the required image size. Upsampling uses Bilinear Interpolation to maintain visual quality. This gives a large improvement in performance, with minimal impact on visual quality for small cell sizes (for instance, 10 pixels or less).To ensure that the computed surface is stable (i.e. does not display obvious edge artifacts under zooming and panning), the data extent is expanded to be larger than the specified output extent. The expansion distance is equal to the size of
radiusPixels
in the input CRS.Parameters
M = mandatory, O = optional- data (M) - the FeatureCollection containing the point observations
- radiusPixels (M)- the density kernel radius, in pixels
- weightAttr (M)- the feature type attribute containing the observed surface value
- pixelsPerCell (O) - The pixels-per-cell value determines the resolution of the computed grid. Larger values improve performance, but degrade appearance. (Default = 1)
- outputBBOX (M) - The georeferenced bounding box of the output area
- outputWidth (M) - The width of the output raster
- outputHeight (M) - The height of the output raster
Computation of the surface takes places in the CRS of the output. If the data CRS is different to the output CRS, the input points are transformed into the output CRS.
Using the process as a Rendering Transformation
This process can be used as a RenderingTransformation, since it implements the invertQuery(... Query, GridGeometry) method. In this case thequeryBuffer
parameter should be specified to expand the query extent appropriately. The output raster parameters may be provided from the request extents, using the following SLD environment variables:- outputBBOX - env var = wms_bbox
- outputWidth - env var = wms_width
- outputHeight - env var = wms_height
- Author:
- Martin Davis - OpenGeo
-
-
Constructor Summary
Constructors Constructor Description HeatmapProcess()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GridCoverage2D
execute(SimpleFeatureCollection obsFeatures, Integer argRadiusPixels, String valueAttr, Integer argPixelsPerCell, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, ProgressListener monitor)
protected Filter
expandBBox(Filter filter, double distance)
protected void
extractPoints(SimpleFeatureCollection obsPoints, String attrName, MathTransform trans, HeatmapSurface heatMap)
Extract points from a feature collection, and stores them in the heatmapQuery
invertQuery(Integer argRadiusPixels, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, Query targetQuery, GridGeometry targetGridGeometry)
Given a target query and a target grid geometry returns the query to be used to read the input data of the process involved in rendering.
-
-
-
Method Detail
-
execute
public GridCoverage2D execute(SimpleFeatureCollection obsFeatures, Integer argRadiusPixels, String valueAttr, Integer argPixelsPerCell, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, ProgressListener monitor) throws ProcessException
- Throws:
ProcessException
-
invertQuery
public Query invertQuery(Integer argRadiusPixels, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException
Given a target query and a target grid geometry returns the query to be used to read the input data of the process involved in rendering. In this process this method is used to:- determine the extent & CRS of the output grid
- expand the query envelope to ensure stable surface generation
- modify the query hints to ensure point features are returned
- Parameters:
argRadiusPixels
- the feature type attribute that contains the observed surface valuetargetQuery
- the query used against the data sourcetargetGridGeometry
- the grid geometry of the destination image- Returns:
- The transformed query
- Throws:
ProcessException
-
extractPoints
protected void extractPoints(SimpleFeatureCollection obsPoints, String attrName, MathTransform trans, HeatmapSurface heatMap) throws CQLException
Extract points from a feature collection, and stores them in the heatmap- Parameters:
obsPoints
- features to extractattrName
- expression or property name used to evaluate the geometry from a featuretrans
- transform for extracted pointsheatMap
- heatmap to add points to- Throws:
CQLException
- if attrName can't be parsed
-
-