Statistics Glossary → KDE Density Map
KDE Density Mapanalysis
A kernel density estimation map that builds a continuous density surface from point locations, by adding up smooth 'bumps' spread around each point, to show where the points are concentrated.
Concept
When hundreds of points overlap on a map, it is hard to tell by eye where they are concentrated; counting them within administrative boundaries, on the other hand, makes the result depend on how those boundaries were drawn. Kernel density estimation (KDE) turns each point into a small bump called a kernel and adds these bumps together to obtain a continuous density surface across the area. The result is the number of points per unit area (e.g. points per km²).
The shape of the surface is set mostly by the bandwidth: how widely each bump spreads. A narrow bandwidth produces many small, sharp peaks; a wide one produces a few gentle peaks. The bandwidth can be chosen by a rule of thumb (Silverman, Scott) or from the data by cross-validation. If desired, each point can be weighted by a value (e.g. the number of people involved in an incident), and volume contours draw the smallest areas that contain a given share of the total density (50%, 95%).
KDE is descriptive: it does not test statistically whether the points are clustered, it only shows where they are concentrated. Because peak values depend on the bandwidth, they should be read in relative rather than absolute terms. Density can look too low near the edge of the study area (edge effect); and unless the number of events is related to a population 'at risk', such as residents or traffic, density should not be read directly as risk.
When to use it
- To see, as a continuous surface, where events, trees, visitors or observation points are concentrated within an area.
- If counting and summarising the points in regular cells is enough, use Hexbin; if it must be tested whether the dense areas could arise by chance, use point pattern analysis (Ripley's K, Clark-Evans).
- If the points are to be split into separate clusters with each point assigned to one, use DBSCAN; if a surface of a value measured at the points (e.g. pollutant concentration) is wanted, kriging is preferred.
An everyday example
A city council maps the locations of 400 cycling accidents that happened in the city over the last three years. Because the points overlap on the map, it is not clear which area is more dangerous. The KDE map shows, for example, two distinct peaks: around the university campus and at a junction on the coastal road. When the 50% volume contour marks a small area containing half of the accidents, the council can start redesigning cycle lanes there; but it should also take into account that these areas carry more cycle traffic.
Parameters in MerQur
Classify by (none - single color, categorical column)
Concept: Shows the points in different colours according to a categorical column before the analysis. It is a data-exploration step and does not change the density calculation.
Everyday example: Colouring the cycling accidents as 'with injury' and 'damage only' lets one see at a glance, before drawing the density map, whether injury accidents cluster on particular roads.
What it does: Colours the point map by a categorical column before the analysis; it is for data exploration.
Effect on the result: Does not change the density surface, the bandwidth or the contours; only the preview colours change.
On the validation data: Not tested, since it does not enter the analysis.
Method (KDE, Hexbin, Getis-Ord Gi*, DBSCAN, Moran's I, Variogram + Kriging)
Concept: Chooses which spatial method is run on the map tab. KDE gives the density of points as a continuous surface; the other methods answer different questions such as cell counts, hot spots, clustering, autocorrelation or interpolation.
Everyday example: If the council asks 'where are accidents concentrated?', KDE is chosen. Had it asked 'could this concentration be due to chance?' or 'into which clusters do the accidents fall?', another method would be needed.
What it does: Selects the method to be run in the Map tab; this section covers the KDE option.
Effect on the result: The other methods are covered in their own sections.
On the validation data: The KDE selection is validated.
Palette (Viridis, Plasma, Jet)
Concept: Sets the colour scale used to display the density values; it does not change the computed surface. Perceptually uniform palettes such as Viridis and Plasma reflect value differences more faithfully than rainbow palettes such as Jet and are also readable for people with colour-vision deficiency.
Everyday example: The same accident density map in the Jet palette can appear to have artificial boundaries at the yellow-to-red transitions. In Viridis the density increases smoothly and without breaks.
What it does: Determines the map colour scale.
Effect on the result: Does not change the density grid or the contours; affects only the appearance.
On the validation data: The density grid stays the same with Plasma and Jet (expected no effect).
Bandwidth (Silverman, Scott, Manual, Scott normal, Likelihood CV, Berman-Diggle CV)
Concept: The bandwidth is the width of the kernel spread around each point, and it sets how rough the surface is. Rule-based methods (Silverman, Scott) compute a quick value from the spread of the data; cross-validation methods search for the bandwidth that best fits the data and usually choose a narrower one for clustered data.
Everyday example: With the Silverman bandwidth, the accident map shows two broad peaks at the campus and the coastal road. A narrower bandwidth chosen by cross-validation may reveal individual junctions within those areas as separate peaks.
What it does: Determines the standard deviation (km) of the Gaussian kernel; controls the roughness of the surface. Silverman, Scott and Scott normal are rule-based; Likelihood CV (bw.ppl) and Berman-Diggle CV (bw.diggle) choose the bandwidth by cross-validation.
Effect on the result: As the bandwidth gets smaller the peak density rises and the surface fragments; as it grows it flattens. For clustered points the cross-validation options are preferred; Berman-Diggle tends to choose a small bandwidth.
On the validation data: In redwood Silverman hx/hy 0.1068/0.1081 km, peak 138.9; Scott 0.1362/0.1379 km, peak 101.5; Likelihood CV 0.0447 km, peak 367.3; Berman-Diggle CV 0.0224 km, peak 814.7.
Bandwidth (km) (active only when "Manual" is selected; at least 0.01)
Concept: Sets the bandwidth as a distance (km) given by the user instead of by a rule. It is useful when a theoretical or practical scale of the phenomenon is known, or when maps from different studies are to be compared with the same bandwidth.
Everyday example: If the council reckons 'a junction's influence extends about 200 metres around it', the bandwidth is set to 0.2 km. If the same bandwidth is used for next year's accident map, the two years can be compared fairly.
What it does: Uses the bandwidth given by the user instead of a rule; useful when the theoretical scale is known (e.g. walking distance) or for comparison across studies.
Effect on the result: Determines all density outputs; not used unless Bandwidth is "Manual".
On the validation data: In redwood, 0.05 km peak 330.3, 0.10 km 152.8, 1.00 km 9.18 points/km2.
Kernel type (Gaussian, Quartic/biweight, Epanechnikov, Triweight)
Concept: The kernel is the shape that sets how each point's influence declines with distance. The Gaussian kernel keeps its influence, ever smaller, without limit; the Quartic, Epanechnikov and Triweight kernels fall exactly to zero at a set radius. Results are usually more sensitive to the bandwidth than to the kernel.
Everyday example: With a Quartic kernel and a 200-metre radius, each accident contributes only to the density within 200 metres of it. With a Gaussian kernel, a distant accident also makes a very small contribution.
What it does: Uses a radial kernel with bounded support instead of the Gaussian; in this case the bandwidth is the radius r. Quartic is the kernel commonly used in heat maps.
Effect on the result: Points beyond r make no contribution. The automatic radius is r = c x sqrt(hx x hy); c = 2.77919 (quartic), 2.40187 (Epanechnikov), 3.11540 (triweight).
On the validation data: At manual r = 0.20 km the peaks are 215.6 / 170.2 / 248.2. Automatic r: quartic 0.29870, Epanechnikov 0.25814, triweight 0.33483 km.
→ Kernel (weighting) function (Gaussian, bisquare, Epanechnikov)
Edge correction (None, Bounding rectangle, Convex hull)
Concept: For points near the edge of the study area, part of the kernel spills outside the area and is not counted, so density looks too low at the edges. Edge correction compensates by scaling the density up according to the share of the kernel that lies inside the area.
Everyday example: If the coastal road lies right at the edge of the study area, part of the kernel of accidents there falls into the sea, outside the area, and the density looks low. Edge correction makes up for this loss and better shows the true density on the coastal road.
What it does: Increases the density by the kernel mass spilling outside the observation window. It is used only with the Gaussian kernel; with another kernel an explicit error message is given.
Effect on the result: Increases the density near the boundary; the peak density may be in a boundary cell.
On the validation data: In redwood, with the rectangle the peak is 222.2 (138.9 without correction), the smallest e(u) 0.25; with the hull the peak is 312.9.
Volume contours ([Parameters] check box)
Concept: A volume contour is the boundary of the smallest area that contains a given share of the total density (50%, 95%). In ecology it is used to define an animal's 'home range'; the 50% contour shows the core area and the 95% contour the general area of use.
Everyday example: The 50% contour marks an area that covers only a small part of the city but holds half of the accidents. By spending its limited budget inside this contour first, the council can target the most accidents in the smallest area.
What it does: Draws the boundaries of the smallest areas covering 50% and 95% of the total density (home range; Worton 1989). The areas are given in the summary note.
Effect on the result: Does not change the density surface, produces additional output.
On the validation data: In redwood the 50% area is 0.327 km2, the 95% area 1.116 km2 (grid mass definition); 0.140 and 0.673 km2 with the ks sample-percentile definition.
Value (none, numeric column)
Concept: Weights each point by a numeric value, so that the surface shows the amount of value per unit area instead of the density of points.
Everyday example: If each accident is weighted by the number of people injured, the map answers 'where are injuries frequent?' rather than 'where are accidents frequent?'. A hill with few but serious accidents stands out more on this map.
What it does: Weights each point by the value in the selected column; points with missing values are excluded, a negative value gives an error.
Effect on the result: The density unit becomes value/km2.
On the validation data: In Boston the CMEDV-weighted peak is 92.36 value/km2.
Longitude convention (automatic)
Concept: Some data sources record longitude from 0 to 360, others from −180 to 180; in data crossing the 180th meridian this difference pushes points on either side artificially far apart. The rule converts longitudes to a single convention so that distances are computed correctly.
Everyday example: For an accident map within a city this rule makes little difference. But for someone mapping shipping accidents among Pacific islands, accidents on either side of the meridian would be flung to opposite ends of the map without it.
What it does: Converts longitudes given in the 0-360 form to -180..180 and reports the count in the note; for data crossing the 180th meridian the central longitude is taken by circular mean and longitude differences are wrapped.
Effect on the result: For data crossing the meridian the bandwidth and density are computed on the correct scale (km); no point is dropped.
On the validation data: In quakes 708 values are converted to the equirectangular (eqc) plane; Silverman hx 62.85 km, peak 0.00221 points/km2.
Example on real data
Data: Strauss 1975, spatstat.data redwood
Variables: locations of 62 redwood seedlings (latitude/longitude); no value column
- Question: Where in the plot are the 62 redwood seedlings concentrated?
- Method: Two-dimensional KDE with a Gaussian kernel; Silverman bandwidth hx = 0.107 km, hy = 0.108 km; 100 x 100 grid, local plane in km.
- Result: The highest density is 138.9 points/km²; the surface shows several separate peaks (seedling clusters), the seedlings are not spread evenly over the plot.
- Bandwidth effect: The bandwidth sets the smoothness of the surface; Scott's rule (n^(-1/6)) gives a wider bandwidth and the peak falls to 101.5. The peak value depends on the bandwidth choice and should be read as relative, not absolute.
- Limitation: KDE is descriptive; it does not test whether the clustering differs from randomness (for that, point pattern analysis, G07).
- Report line: Gaussian KDE (Silverman bandwidth hx = 0.107 km, hy = 0.108 km, n = 62) gave a highest density of 138.9 points/km².
Related concepts
Bandwidth (kernel smoothing)Kernel density estimation (KDE)Edge (boundary) correctionKernel (weighting) function (Gaussian, bisquare, Epanechnikov)Kriging (simple, ordinary, universal, block)Observation window (study region)Spatial autocorrelation (Moran's I, Geary's C)Local indicators of spatial association (LISA) and Gi*
The numbers in the examples are MerQur's output on independent, publicly available validation data; see the MerQur Technical Note for details.