1

I have 5 large point datasets (shapefiles) and I'm interested in getting a heatmap on the combination of all 5 point layers.

I use the QGIS heatmap tool to create a heatmap on each layer. This is the tool: enter image description here

Here's the parameters for the tool: enter image description here

I run this tool for all 5 point layers to have 5 different heat maps, which have some pixels overlapping and other pixels on their own.

I.e. the rasters do not cover the same extent.

I need to add these values together (as in addition '+').

But, when I use Raster Calculator to 'add' them together, the pixels on their own disappear. I tried many different calculations, such as Raster1 + Raster2; Raster1 OR Raster2; (Raster1 + Raster1) /2 + (Raster1 + Raster1) /2 but still the same issue with data vanishing where the two layers don't overlap.

I also tried to make a large raster that covers the whole point layers area, with each pixel valued 0, but the size of the pixels were not the same! This larger raster was used to attempt to add all the other Heat Map rasters so I wouldn't be performing arithmetic on empty space. I'm not sure if the different sized raster pixels would be an issue. Making that huge raster with the same (tiny) size of the pixels in the heatmap layer is a bit impractical because it would be too big to process.

I tried nan_to_num() but still the same result.

enter image description here

Before (i.e. multiple Heat Maps). You can see 3 areas: enter image description here

After (i.e. one combined Heat Map). You can see 2 slightly smaller areas: enter image description here

How do I stop these pixels from disappearing, particularly where the layers don't overlap?

1 Answer 1

1

You are running into the problem of NoData or Null values, which as you've seen are ignored in the output and act as a mask.

For each raster, you could use nan_to_num() in your formula. It's from the numpy library.

Try, nan_to_num(raster1@1) + nan_to_num(raster2@1) + ...

nan_to_num() will take all null/nodata values and convert them to 0.

If you need a specific value other than 0, use the grass tool r.null.to on each raster before getting the sum for all of them.

2
  • I just tried and it's still only outputting the intersect. I'll update my question..
    – LHo
    May 14, 2019 at 1:02
  • @Joe that's odd. might be a bug cause the raster calculator docs mention that it should adjust the region/extent to that of all the inputs. Maybe double check that the cell size and projection of the rasters are indeed identical.
    – SaultDon
    May 15, 2019 at 19:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.