pyinterp.geometry.cartesian.LineString

Contents

pyinterp.geometry.cartesian.LineString#

class pyinterp.geometry.cartesian.LineString(self)#
class pyinterp.geometry.cartesian.LineString(self, xs: numpy.ndarray[dtype=float64, shape=(*), writable=False], ys: numpy.ndarray[dtype=float64, shape=(*), writable=False])

Bases: object

A linestring in Cartesian coordinates.

A LineString is an ordered sequence of points describing an open path on a flat plane. Unlike a Ring, the linestring is not automatically closed.

Examples

>>> import numpy as np
>>> from pyinterp.geometry.cartesian import LineString
>>> x = np.array([0.0, 5.0, 10.0])
>>> y = np.array([0.0, 5.0, 0.0])
>>> line = LineString(x, y)
>>> len(line)
3

Overloaded function.

  1. __init__(self) -> None

Construct an empty linestring.

  1. __init__(self, xs: numpy.ndarray[dtype=float64, shape=(*), writable=False], ys: numpy.ndarray[dtype=float64, shape=(*), writable=False]) -> None

Construct a linestring from x and y arrays.

Parameters:
  • x – Array of x coordinate values.

  • y – Array of y coordinate values (must have same size as x).

Raises:

ValueError – If x and y arrays have different sizes.

Public Methods

append(self, point)

Append a point to the linestring.

clear(self)

Remove all points from the linestring.

to_arrays(self)

Get the coordinate arrays of the linestring points.

Special Methods

__bool__(self)

Return True if the linestring is not empty.

__eq__(self, other)

Check if two linestrings are equal.

__getitem__(self, idx)

Get the point at the given index.

__getstate__(self)

Return the state of the LineString for pickling.

__iter__(self)

Return an iterator over the points in the linestring.

__len__(self)

Return the number of points in the linestring.

__ne__(self, other)

Check if two linestrings are not equal.

__new__(*args, **kwargs)

__repr__(self)

Return the official string representation of the LineString.

__setitem__(self, idx, point)

Set the point at the given index.

__setstate__(self, state)

Restore the state of the LineString from pickling.

__str__(self)

Return the informal string representation of the LineString.