Random sample

This tool can be used to create a random sample of grid cells. The user specifies the base raster file, which is used to determine the grid dimensions and georeference information for the output raster, and the number of sample random samples (n). The output grid will contain n non-zero grid cells, randomly distributed throughout the raster grid, and a background value of zero. This tool is useful when performing statistical analyses on raster images when you wish to obtain a random sample of data.

See Also:

Scripting:

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

wd = pluginHost.getWorkingDirectory()
inputFile = wd + "input.dep"
outputFile = wd + "output.dep"
numPoints = "1000"
args = [inputFile, outputFile, numPoints]
pluginHost.runPlugin("RandomSample", args, False)

This is a Groovy script also using this tool:

def wd = pluginHost.getWorkingDirectory()
def inputFile = wd + "input.dep"
def outputFile = wd + "output.dep"
def numPoints = "1000"
String[] args = [inputFile, outputFile]
pluginHost.runPlugin("RandomSample", args, false)

Credits: