public class HeatmapProcess extends Object implements VectorProcess
HeatmapSurface
to compute a heatmap surface over a set of irregular
data points as a GridCoverage
. 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.
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.
queryBuffer
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:
Constructor and Description |
---|
HeatmapProcess() |
Modifier and Type | Method and 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 heatmap
|
Query |
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.
|
public GridCoverage2D execute(SimpleFeatureCollection obsFeatures, Integer argRadiusPixels, String valueAttr, Integer argPixelsPerCell, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, ProgressListener monitor) throws ProcessException
ProcessException
public Query invertQuery(Integer argRadiusPixels, ReferencedEnvelope argOutputEnv, Integer argOutputWidth, Integer argOutputHeight, Query targetQuery, GridGeometry targetGridGeometry) throws ProcessException
argRadiusPixels
- the feature type attribute that contains the observed surface valuetargetQuery
- the query used against the data sourcetargetGridGeometry
- the grid geometry of the destination imageProcessException
protected void extractPoints(SimpleFeatureCollection obsPoints, String attrName, MathTransform trans, HeatmapSurface heatMap) throws CQLException
obsPoints
- features to extractattrName
- expression or property name used to evaluate the geometry from a featuretrans
- transform for extracted pointsheatMap
- heatmap to add points toCQLException
- if attrName can't be parsedCopyright © 1996–2023 Geotools. All rights reserved.