Number of grid cells

This tool simply counts the number of valid grid cells in a raster grid. For a grid that is completely filled with valid data values, this will simply be the number of rows multiplied by the number of columns. For grids containing either NoData or, optionally a zero-valued background, the number of grid cells is less than the total number of grid cells.

Scripting:

The following is an example of a Python script using this tool:

wd = pluginHost.getWorkingDirectory()
# You may have multiple input files but they must
# be separated by semicolons in the string.
inputFiles = wd + "input1.dep" + ";" + wd + "input2.dep" + ";" + wd + "input3.dep"
noZeros = "false"
args = [inputFiles, noZeros]
pluginHost.runPlugin("NumberOfGridCells", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
// You may have multiple input files but they must
// be separated by semicolons in the string.
def inputFiles = wd + "input1.dep" + ";" + wd + "input2.dep" + ";" + wd + "input3.dep"
def noZeros = "true"
String[] args = [inputFiles, noZeros]
pluginHost.runPlugin("NumberOfGridCells", args, false)

Credits: