clouddrift.pairs.pair_bounding_box_overlap

clouddrift.pairs.pair_bounding_box_overlap#

clouddrift.pairs.pair_bounding_box_overlap(lon1: list[float] | ndarray[float] | Series | DataArray, lat1: list[float] | ndarray[float] | Series | DataArray, lon2: list[float] | ndarray[float] | Series | DataArray, lat2: list[float] | ndarray[float] | Series | DataArray, distance: float | None = 0) tuple[ndarray[bool], ndarray[bool]][source]#

Given two arrays of longitudes and latitudes, return boolean masks for their overlapping bounding boxes.

Parameters#

lon1array_like

First array of longitudes in degrees.

lat1array_like

First array of latitudes in degrees.

lon2array_like

Second array of longitudes in degrees.

lat2array_like

Second array of latitudes in degrees.

distancefloat, optional

Distance in degrees for the overlap. If the overlap is within this distance, the bounding boxes are considered to overlap. Default is 0.

Returns#

overlap1np.ndarray[int]

Indices lon1 and lat1 where their bounding box overlaps with that of lon2 and lat2.

overlap2np.ndarray[int]

Indices lon2 and lat2 where their bounding box overlaps with that of lon1 and lat1.

Examples#

>>> lon1 = [0, 0, 1, 1]
>>> lat1 = [0, 0, 1, 1]
>>> lon2 = [1, 1, 2, 2]
>>> lat2 = [1, 1, 2, 2]
>>> pair_bounding_box_overlap(lon1, lat1, lon2, lat2, 0.5)
(array([2, 3]), array([0, 1]))