raster_tools.random_raster#

raster_tools.random_raster(template=None, distribution='normal', bands=1, params=(1, 0.5), copy_mask=False, *, raster_template=None)[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
  • template (Raster, str, or odc.geo.geobox.GeoBox) – Template defining rows, columns, crs, resolution, etc. A path string is loaded as a Raster. A GeoBox supplies only the grid; in that case copy_mask is invalid and no mask/null value is propagated.

  • 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 the template, the first band’s mask is copied bands times. Only valid when template is a Raster.

Returns

The resulting raster of random values pulled from the distribution.

Return type

Raster