pyinterp.geometry.cartesian.Polygon

Contents

pyinterp.geometry.cartesian.Polygon#

class pyinterp.geometry.cartesian.Polygon(self)#
class pyinterp.geometry.cartesian.Polygon(self, exterior: pyinterp.core.geometry.cartesian.Ring | None = None, interiors: collections.abc.Sequence[pyinterp.core.geometry.cartesian.Ring] | None = None)

Bases: object

A polygon in Cartesian coordinates.

A Polygon is defined by an exterior ring and zero or more interior rings (holes). The exterior ring is indexed at position 0; interior rings start at index 1.

Examples

>>> import numpy as np
>>> from pyinterp.geometry.cartesian import Polygon, Ring
>>> outer = Ring(np.array([0.0, 10.0, 10.0, 0.0, 0.0]),
...              np.array([0.0, 0.0, 10.0, 10.0, 0.0]))
>>> poly = Polygon(outer)
>>> len(poly)
1

Overloaded function.

  1. __init__(self) -> None

Construct an empty polygon.

  1. __init__(self, exterior: pyinterp.core.geometry.cartesian.Ring | None = None, interiors: collections.abc.Sequence[pyinterp.core.geometry.cartesian.Ring] | None = None) -> None

Construct a polygon from an exterior ring and optional interior rings.

Parameters:
  • exterior – Exterior ring defining the polygon boundary.

  • interiors – Optional sequence of interior rings (holes).

Attributes

inners

View over interior rings bound to polygon lifetime.

outer

Exterior ring of the polygon.

Public Methods

append(self, ring)

Append an interior ring (hole).

clear(self)

Remove the exterior and all interior rings.

Special Methods

__eq__(self, other)

Check if two polygons are equal.

__getstate__(self)

Return the state of the Polygon for pickling.

__ne__(self, other)

Check if two polygons are not equal.

__new__(*args, **kwargs)

__repr__(self)

Return the official string representation of the polygon.

__setstate__(self, state)

Restore the state of the Polygon from pickling.

__str__(self)

Return the informal string representation of the polygon.