pyinterp.geometry.geographic.Polygon

Contents

pyinterp.geometry.geographic.Polygon#

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

Bases: object

A polygon in geographic 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.geographic 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

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 serialized state 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 polygon from the serialized state.

__str__(self)

Return the string representation of the polygon.