# Understanding the Heatmap tool values in QGIS

Context

I have been having a play around with the Heatmap (Kernel Density Estimation) tool in QGIS 3.4 and I realised that I do not really understand the output.

My understanding was that you choose the radius at which you want to analyse your point data with and the output will show you how many points can be found within a circle of chosen radius from any point in the output raster. I now know this to be wrong after looking at the results.

Example

Input

I have 3 points that I want to run the heatmap analysis (red circles) on and want to use a radius of 8 kilometers. I choose a pixel size of 100 (I understand the effect that varying pixels sizes can have on an output) and select the Quartic kernel shape (because it was default). Decay ratio is set to 0.

Output

The output can be seen in the below image. I have marked the raster values along a singular radius of each circle.

Question

What are these values telling me about that specific location in the heatmap and for a larger data set how could I make a heatmap where these values are meaningful to an audience who might not be as adept (I am clearly one of them!).

Heatmaps basically (1) aggregate large amounts of point data so they are easier to visualize and (2) provide an estimation of the density of data for every point in an area of interest, even if you don't have data for every point!

Let's say your 3 points are car accidents. You know three accidents happened, but maybe there is a way to estimate how "dangerous" every point (or pixel) in your area of interest is, based only on what you know for sure.

So, the first thing you do is set a radius - each data point will now be the center point of a circle with this radius. Let's call that the point's "area of influence". If a pixel falls within this radius, we'll say it's more "dangerous" than if it was outside of the radius.

But, it won't be black-and-white - we will lower the "danger" number based on how far away our unknown pixel is from the data point. For simplicity, let's say we give the pixel a danger-level of 0 if it's outside the radius, a level of 1 if it's directly on top of our data point, and something in between in all other cases...

But what if our pixel falls within the radius of more than one data point? That's when a heatmap starts to look like a measurement of density. We need to start summing the "danger-values" for each of the radii. Think about it, if we have a point that is halfway from all three points, we can give it a danger value of 1.5 (0.5 + 0.5 + 0.5).

So the values are relative. They reflect the number of points whose radii include the pixel, and how far the pixel is from each of those points. A pixel will be "dangerous" if it is very close to a few points, but also if it is less close but still within the radius of many points.

Our measure of density was simple here, but it's not so different from the way the QGIS tool does the calculation. The maximum value will depend on the distribution you chose for your estimation, (which is a bit more technical). More information can be found about distributions for heatmaps on this helpful explanatory page.

• thank you for your answer, do you know if there is a way to do this based on my wrong understanding explained in the Context above. Commented Nov 1, 2018 at 16:45
• I'm relatively new here, but I think what you're asking would justify posting another question. Anyway, if what you want is to draw a cirlce of radius r from each point, and count the number of other points within each circle, you could make a fixed distance buffer on your point layer (QGIS tool "Buffer" in QGIS3 or "Fixed distance buffer" in 2.18), then use the processing tool "Count points in polygon", with the buffer as your polygon and the original points as your point layer. That will return a layer of circle polygons with a data field counting the number of points within each one.
– pabs
Commented Nov 2, 2018 at 11:51
• It would be important not to set the buffer to "dissolve" in your particular case. These kinds of details are why a separate question might be better.
– pabs
Commented Nov 2, 2018 at 12:02