raster_tools.random_raster#

raster_tools.random_raster(raster_template, distribution='normal', bands=1, params=(1, 0.5), copy_mask=False)[source]#

Creates a Raster of random values based on the desired distribution.

This function uses dask.array.random to generate data. The default is a normal distribution with mean of 1 and standard deviation of 0.5.

Parameters
  • raster_template (Raster, str) – A template raster used to define rows, columns, crs, resolution, etc.

  • distribution (str, optional) –

    Random distribution type. Default is ‘normal’. See params parameter below for passing additional distribution parameters. Valid values are:

    ’binomial’

    Binomial distribution. Uses two additional parameters: (n, p).

    ’normal’

    Normal distribution. Uses two additional parameters: (mean, std). This is the default.

    ’poisson’

    Poisson distribution. Uses one additional parameter.

    ’uniform’

    Uniform distribution in the half-open interval [0, 1). Uses no additional.

    ’weibull’

    Weibull distribution. Uses one additional parameter.

  • bands (int, optional) – Number of bands needed desired. Default is 1.

  • params (list of scalars, optional) – Additional parameters for generating the distribution. For example distribution=’normal’ and params=(1, 0.5) would result in a normal distribution with mean of 1 and standard deviation of 0.5. Default is (1, 0.5).

  • copy_mask (bool) – If True, the template raster’s mask is copied to the result raster. If bands differs from raster_template, the first band’s mask is copied bands times.

Returns

The resulting raster of random values pulled from the distribution.

Return type

Raster