shapely.linestrings#
- linestrings(coords, y=None, z=None, indices=None, out=None, **kwargs)#
Create an array of linestrings.
This function will raise an exception if a linestring contains less than two points.
- Parameters:
- coordsarray_like
An array of lists of coordinate tuples (2- or 3-dimensional) or, if
y
is provided, an array of lists of x coordinates- yarray_like, optional
- zarray_like, optional
- indicesarray_like, optional
Indices into the target array where input coordinates belong. If provided, the coords should be 2D with shape (N, 2) or (N, 3) and indices should be an array of shape (N,) with integers in increasing order. Missing indices result in a ValueError unless
out
is provided, in which case the original value inout
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.
Notes
Usage of the
y
andz
arguments will prevents lazy evaluation indask
. Instead provide the coordinates as a(..., 2)
or(..., 3)
array using onlycoords
.
Examples
>>> linestrings([[[0, 1], [4, 5]], [[2, 3], [5, 6]]]).tolist() [<LINESTRING (0 1, 4 5)>, <LINESTRING (2 3, 5 6)>] >>> linestrings([[0, 1], [4, 5], [2, 3], [5, 6], [7, 8]], indices=[0, 0, 1, 1, 1]).tolist() [<LINESTRING (0 1, 4 5)>, <LINESTRING (2 3, 5 6, 7 8)>]