I have ~90 .tif files that are rasters of known fire boundaries from the last 90 years. I want to merge them so that each pixel has the value of the number of fires occurring at that pixel. I can merge the raster files OK, but then each layer becomes a band, "nodata" sections become 0s, and the value of each pixel is the year (see table below from the identify function).

What is displayed in the merged raster file

As you can see, this has "worked" in that I can click any pixel and see where there has been fires and when. What I now need to do is either sum or stylize this layer so that is shows the number of fire events (intervals not important). I cannot sum the value column as the value is the year rather than a "1" to correspond to a fire event.

Zonal statistics doesn't help me here because I need a viewable map rather than a table.

I have very little experience with raster-based GIS.

  • Have a read of docs.qgis.org/3.16/en/docs/user_manual/processing_algs/qgis/… and search for the keyword 'count', this will result in a raster with the count of not 0 if you set the nodata for the band to 0. – Michael Stimson Feb 22 at 4:32
  • 1
    Thanks Michael, that seems to be exactly what I need. Thanks for the incredibly speedy response. For what its worth, for access to this feature I needed to upgrade to QGIS 3.16 (was on 3.10 - the long-term release). If you can be bothered putting this in an answer I can mark closed, or otherwise I can write it out. Cheers. – sleepy Feb 22 at 5:02
  • Feel free to answer your own question with screen shots and links, I'll come back in an hour or two and upvote it. – Michael Stimson Feb 22 at 5:20

Michael Stimson's comment has the appropriate answer to this question.

This can be done by using the "cell statistics" (Processing Toolbox -> Raster Analysis -> Cell statistics). The associated documentation can be found here. You will need version 3.16 or greater of QGIS to access this feature.

Cell statistics in QGIS 3.16

  1. Select the rasters you want to count overlapping pixels of (Input layers)

  2. Set Statistic to "count" (optional step 2a. You can choose to assign a value to any NoData cell at this stage under Advanced Parameters.)

  3. Run.

If you wish to do other statistics, or understand how the count works with 0s vs NoData, see this excellent diagram from the QGIS diagram for reference. Details on all the available parameters are in this documentation.

Cell statistics options


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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