verde.scatter_points

Contents

verde.scatter_points#

verde.scatter_points(region, size, random_state=None, extra_coords=None)[source]#

Generate the coordinates for a random scatter of points.

The points are drawn from a uniform distribution.

Parameters:
regionlist = [W, E, S, N]

The boundaries of a given region in Cartesian or geographic coordinates.

sizeint

The number of points to generate.

random_statenumpy.random.RandomState or an int seed

A random number generator used to define the state of the random permutations. Use a fixed seed to make sure computations are reproducible. Use None to choose a seed automatically (resulting in different numbers with each run).

extra_coordsNone, scalar, or list

If not None, then value(s) of extra coordinate arrays to be generated. These extra arrays will have the same size as the others but will contain a constant value. Will generate an extra array per value given in extra_coords. Use this to generate arrays of constant heights or times, for example, that might be needed to evaluate a gridder.

Returns:
coordinatestuple of arrays

Arrays with coordinates of each point in the grid. Each array contains values for a dimension in the order: easting, northing, vertical, and any extra dimensions given in extra_coords. All arrays will have the specified size.

See also

grid_coordinates

Generate coordinates for each point on a regular grid

profile_coordinates

Coordinates for a profile between two points

Examples

>>> # We'll use a seed value will ensure that the same will be generated
>>> # every time.
>>> easting, northing = scatter_points((0, 10, -2, -1), 4, random_state=0)
>>> print(', '.join(['{:.4f}'.format(i) for i in easting]))
5.4881, 7.1519, 6.0276, 5.4488
>>> print(', '.join(['{:.4f}'.format(i) for i in northing]))
-1.5763, -1.3541, -1.5624, -1.1082
>>> easting, northing, height = scatter_points(
...     (0, 10, -2, -1), 4, random_state=0, extra_coords=12
... )
>>> print(height)
[12. 12. 12. 12.]
>>> easting, northing, height, time = scatter_points(
...     (0, 10, -2, -1), 4, random_state=0, extra_coords=[12, 1986])
>>> print(height)
[12. 12. 12. 12.]
>>> print(time)
[1986. 1986. 1986. 1986.]