# Counting occurrences across many rasters using ArcGIS Desktop?

I am interested in drought occurrences in the US, especially how often droughts of a particular severity occur in particular regions. I’ve got nice vector maps from http://droughtmonitor.unl.edu showing drought severity for each year (scale of 0 - 4, with 0 = minor drought and 4 = extreme drought) for 2006 - 2017. I’ve converted the vector maps to rasters, all with the same extent and cell size.

Using ArcMap 10.5 (and prob Spatial Analyst), I want to count how many times a drought index of each level has occurred in a given region (i.e. raster cell) over the 10 year period. I’m imagining inputting the 10 yearly maps and ending up with 5 output rasters, each holding the count of drought level for each cell. So far I haven’t found a way to count occurrences across multiple rasters. I don’t want sum or weighted average, I want counts. Any suggestions?

• An easy workaround with a sum would be to first change the 10 raster values to be scaled by successive powers of 10. Then it'd be easy to get the counts from the sum. – lynxlynxlynx Apr 14 '18 at 17:24
• What a truly interesting overlay operation! It reminds me of Excel's countif operation. If you're open to other software, then I have just submitted a new CountIf tool for WhiteboxTools here: github.com/jblindsay/whitebox-tools/blob/master/src/tools/… – WhiteboxDev Apr 14 '18 at 18:39
• If you would like more info on how to use the new tool, let me know. It will count the number of occurrences of a specified value on a cell-by-cell basis for an image stack. I think that is what you are aiming to do. You would need to run it three times, once for each drought index. – WhiteboxDev Apr 14 '18 at 18:43
• Use combine tool from spatial analyst. – FelixIP Apr 14 '18 at 19:23
• As @FelixIP advised Combine is the way. It can be processed a simple model builder model. Iterate your raster dataset by the workflow of Combine>add and calculate a field for the years>merge the tables. Then you can either manipulate the table in excel or ArcGIS’s Pivot Table tool can let you investigate specific cases. – fatih_dur Apr 15 '18 at 4:35

Table below is an output of Combine tool using 6 input rasters (tool can take upto 20). I added column ZEROS to it and populated using:

``````[ !G01!, !G02!, !G03!, !G04!, !G05!, !G06!].count(0)
``````

The simplest way to to create raster from that column is Lookup tool.

BTW same result can be achieved by using Union tool on original polygons, if you have advanced license that can take more than 2 inputs.

Ultimately I found the simplest approach was using the shapefiles and Union. But I also found a direct way to count occurrences across multiple rasters using the “Equal to Frequency” tool (http://desktop.arcgis.com/en/arcmap/10.3/tools/spatial-analyst-toolbox/equal-to-frequency.htm)

My workflow ended up as this:

1. Convert all shapefiles to rasters, making sure all have exact same extent and cell size (and changed the drought index scale from 0-4 to 1-5)
2. Create “value rasters” with same extent and cell size as above, one value raster for each drought index level
3. In all rasters, convert NoData cells to zero values using Reclassify
4. Run “Equal to Frequency” tool once for each drought index level