# How does QGIS calculate heatmap values?

I made a heatmap from points (with values) in QGIS, and now try to understand what the values in color scale are.

1. Radius 300 map units (meters)
2. Pixel size 10 map units (meters)
3. Point values are 10-100.

In heatmap options, I see the kernel function is uniform.

Result values are 0-0.04 . How are they calculated? I want to recalculate it to some real life scales, sum(values)/area.

A test sample: same parameters (radius 300 meters, pixel 10 meters). All points fall within radius, their sum is 152. The result values are 0-0.04. I don't get where .04 came from.

Test calculation. If I assume radius in heatmap pixels, it's 30 px, then

``````In : 152. / (30 ** 2 * math.pi)
Out: 0.05375900299992909
``````

What is 0.04 then?  ## 1 Answer

Found the answer myself. Check pixel size of raster, then calculate:

`````` sum(point.value for point in circle) / (radius * radius * pi)
``````

Where radius is in pixels (radius / pixel size), and value is what it should be (if all points are in radius, then sum, if only one, then that point value). Select "info tool" (top left on the screenshot), click on respective pixel and see the values are correct. 