xrspatial.terrain.generate_terrain#

xrspatial.terrain.generate_terrain(agg: xarray.core.dataarray.DataArray, x_range: tuple = (0, 500), y_range: tuple = (0, 500), seed: int = 10, zfactor: int = 4000, full_extent: Optional[Union[Tuple, List]] = None, name: str = 'terrain') xarray.core.dataarray.DataArray[source]#

Generates a pseudo-random terrain which can be helpful for testing raster functions.

Parameters
  • x_range (tuple, default=(0, 500)) – Range of x values.

  • x_range – Range of y values.

  • seed (int, default=10) – Seed for random number generator.

  • zfactor (int, default=4000) – Multipler for z values.

  • full_extent (str, default=None) – bbox<xmin, ymin, xmax, ymax>. Full extent of coordinate system.

Returns

terrain – 2D array of generated terrain values.

Return type

xr.DataArray

References

Examples

>>> import numpy as np
>>> import xarray as xr
>>> from xrspatial import generate_terrain
>>> W = 400
>>> H = 300
>>> data = np.zeros((H, W), dtype=np.float32)
>>> raster = xr.DataArray(data, dims=['y', 'x'])
>>> xrange = (-20e6, 20e6)
>>> yrange = (-20e6, 20e6)
>>> seed = 2
>>> zfactor = 10
>>> terrain = generate_terrain(raster, xrange, yrange, seed, zfactor)
>>> terrain.plot.imshow()

(png, hires.png, pdf)

../../_images/xrspatial-terrain-generate_terrain-1.png