shapely.multipoints#

multipoints(geometries, indices=None, out=None, **kwargs)#

Create multipoints from arrays of points

Parameters
geometriesarray_like

An array of points or coordinates (see points).

indicesarray_like, optional

Indices into the target array where input geometries belong. If provided, both geometries and indices should be 1D and have matching sizes. Indices should be in increasing order. Missing indices result in a ValueError unless out is provided, in which case the original value in out is kept.

outndarray, optional

An array (with dtype object) to output the geometries into.

**kwargs

For other keyword-only arguments, see the NumPy ufunc docs. Ignored if indices is provided.

Examples

Multipoints are constructed from points:

>>> point_1 = points([1, 1])
>>> point_2 = points([2, 2])
>>> multipoints([point_1, point_2])
<MULTIPOINT (1 1, 2 2)>
>>> multipoints([[point_1, point_2], [point_2, None]]).tolist()
[<MULTIPOINT (1 1, 2 2)>, <MULTIPOINT (2 2)>]

Or from coordinates directly:

>>> multipoints([[0, 0], [2, 2], [3, 3]])
<MULTIPOINT (0 0, 2 2, 3 3)>

Multiple multipoints of different sizes can be constructed efficiently using the indices keyword argument:

>>> multipoints([point_1, point_2, point_2], indices=[0, 0, 1]).tolist()
[<MULTIPOINT (1 1, 2 2)>, <MULTIPOINT (2 2)>]

Missing input values (None) are ignored and may result in an empty multipoint:

>>> multipoints([None])
<MULTIPOINT EMPTY>
>>> multipoints([point_1, None], indices=[0, 0]).tolist()
[<MULTIPOINT (1 1)>]
>>> multipoints([point_1, None], indices=[0, 1]).tolist()
[<MULTIPOINT (1 1)>, <MULTIPOINT EMPTY>]