pyinterp.geometry.geographic.LineString

Contents

pyinterp.geometry.geographic.LineString#

class pyinterp.geometry.geographic.LineString(self)#
class pyinterp.geometry.geographic.LineString(self, lon: numpy.ndarray[dtype=float64, shape=(*), writable=False], lat: numpy.ndarray[dtype=float64, shape=(*), writable=False])

Bases: object

A linestring in geographic coordinates.

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

Examples

>>> import numpy as np
>>> from pyinterp.geometry.geographic import LineString
>>> lon = np.array([0.0, 5.0, 10.0])
>>> lat = np.array([0.0, 5.0, 0.0])
>>> line = LineString(lon, lat)
>>> len(line)
3

Overloaded function.

  1. __init__(self) -> None

Construct an empty linestring.

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

Construct a linestring from longitude and latitude arrays.

Parameters:
  • lon – Array of longitude values in degrees.

  • lat – Array of latitude values in degrees (must have same size as lon).

Raises:

ValueError – If lon and lat 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 serialized state 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 a string representation of the linestring.

__setitem__(self, idx, point)

Set the point at the given index.

__setstate__(self, state)

Restore the linestring from the serialized state.

__str__(self)

Return an informal string representation of the linestring.