public class HeatmapProcess extends Object implements VectorProcess
HeatmapSurfaceto 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
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
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.
queryBufferparameter 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|
|Modifier and Type||Method and Description|
Extract points from a feature collection, and stores them in the heatmap
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
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 value
targetQuery- the query used against the data source
targetGridGeometry- the grid geometry of the destination image
protected void extractPoints(SimpleFeatureCollection obsPoints, String attrName, MathTransform trans, HeatmapSurface heatMap) throws CQLException
obsPoints- features to extract
attrName- expression or property name used to evaluate the geometry from a feature
trans- transform for extracted points
heatMap- heatmap to add points to
CQLException- if attrName can't be parsed
Copyright © 1996–2020 Geotools. All rights reserved.