pyinterp.geometry.geographic.Box

Contents

pyinterp.geometry.geographic.Box#

class pyinterp.geometry.geographic.Box(self, min_corner: tuple[float, float] | None = None, max_corner: tuple[float, float] | None = None)#

Bases: object

A box (rectangle) in geographic coordinates.

The box is represented by two corner points: the minimum corner (southwest) and the maximum corner (northeast). Coordinates are in degrees.

Examples

>>> import numpy as np
>>> from pyinterp.geometry.geographic import Box

Create box from (-10, 40) to (10, 50)

>>> lon = (-10.0, 40.0)
>>> lat = (10.0, 50.0)
>>> box = Box(lon, lat)
>>> box.min_corner()
Point(lon=-10.0, lat=40.0)
>>> box.max_corner()
Point(lon=10.0, lat=50.0)

Construct a box from longitude and latitude tuples.

Parameters:
  • min_corner – Tuple of (lon_min, lat_min) for the minimum corner.

  • max_corner – Tuple of (lon_max, lat_max) for the maximum corner.

Attributes

max_corner

Maximum corner (northeast) of the box.

min_corner

Minimum corner (southwest) of the box.

Public Methods

centroid(self)

Get the centroid (center point) of the box.

Special Methods

__eq__(self, other)

Check if two boxes are equal.

__getstate__(self)

Return the serialized state for pickling.

__ne__(self, other)

Check if two boxes are not equal.

__new__(*args, **kwargs)

__repr__(self)

Return the official string representation of the box.

__setstate__(self, state)

Restore the box from the serialized state.

__str__(self)

Return the string representation of the box.