pyinterp.geometry.cartesian.Ring#
- class pyinterp.geometry.cartesian.Ring(self)#
- class pyinterp.geometry.cartesian.Ring(self, xs: numpy.ndarray[dtype=float64, shape=(*), writable=False], ys: numpy.ndarray[dtype=float64, shape=(*), writable=False])
Bases:
objectA ring (closed linestring) in Cartesian coordinates.
A ring is a closed sequence of points used as polygon boundaries. The ring automatically closes itself (the last point connects back to the first).
Examples
>>> import numpy as np >>> from pyinterp.geometry.cartesian import Ring
Create a square ring
>>> x = np.array([0.0, 10.0, 10.0, 0.0, 0.0]) >>> y = np.array([0.0, 0.0, 10.0, 10.0, 0.0]) >>> ring = Ring(x, y) >>> len(ring) 5
Overloaded function.
__init__(self) -> None
Construct an empty ring.
__init__(self, xs: numpy.ndarray[dtype=float64, shape=(*), writable=False], ys: numpy.ndarray[dtype=float64, shape=(*), writable=False]) -> None
Construct a ring 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 ring.
clear(self)Remove all points from the ring.
to_arrays(self)Get the coordinate arrays of the ring points.
Special Methods
__bool__(self)Return True if the ring is not empty.
__eq__(self, other)Check if two rings are equal.
__getitem__(self, idx)Get the point at the given index.
__getstate__(self)Return the state of the ring for pickling.
__iter__(self)Return an iterator over the points in the ring.
__len__(self)Return the number of points in the ring.
__ne__(self, other)Check if two rings are not equal.
__new__(*args, **kwargs)__repr__(self)Return the official string representation of the ring.
__setitem__(self, idx, point)Set the point at the given index.
__setstate__(self, state)Restore the state of the ring from pickling.
__str__(self)Return the informal string representation of the ring.