xrspatial.perlin.perlin#
- xrspatial.perlin.perlin(agg: DataArray, freq: tuple = (1, 1), seed: int = 5, name: str = 'perlin') DataArray[source]#
Generate perlin noise aggregate.
- Parameters:
agg (xr.DataArray) – 2D array of size width x height, will be used to determine height/ width and which platform to use for calculation.
freq (tuple, default=(1,1)) – (x, y) frequency multipliers.
seed (int, default=5) – Seed for random number generator.
- Returns:
perlin_agg – 2D array of perlin noise values.
- Return type:
xarray.DataArray
References
Paul Panzer: https://stackoverflow.com/questions/42147776/producing-2d-perlin-noise-with-numpy # noqa
ICA: http://www.mountaincartography.org/mt_hood/pdfs/nighbert_bump1.pdf # noqa
Examples
>>> import numpy as np >>> import xarray as xr >>> from xrspatial import perlin >>> W = 4 >>> H = 3 >>> data = np.zeros((H, W), dtype=np.float32) >>> raster = xr.DataArray(data, dims=['y', 'x']) >>> perlin_noise = perlin(raster) >>> print(perlin_noise) <xarray.DataArray 'perlin' (y: 3, x: 4)> array([[0. , 0.58311844, 0.96620274, 0.58311844], [0. , 0.5796199 , 1. , 0.7346118 ], [0. , 0.5172636 , 0.83896613, 0.697184 ]], dtype=float32) Dimensions without coordinates: y, x