TransWikia.com

Calculating number of overlapping pixels across bands with non-zero values using QGIS

Geographic Information Systems Asked on March 3, 2021

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.

One Answer

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

Correct answer by sleepy on March 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP