xoa.core.poly

xoa.core.poly#

Spherical polygon geometry primitives

Provides spherical area, orientation, Sutherland-Hodgman clipping and overlap area. All functions operate on plain numpy arrays (lon/lat in degrees).

Functions

as_polygons(polygon)

Convert polygons to a list of (lon, lat) arrays of shape (n, 2)

clip_polygon(subject_polygon, clipping_polygon)

Clip subject_polygon against clipping_polygon using Sutherland-Hodgman algorithm.

clip_polygon_against_edge(subject_polygon, ...)

Clip a polygon against a single edge using Sutherland-Hodgman algorithm.

compute_intersection(p1, p2, p3, p4)

Compute intersection point between two line segments.

compute_overlap_area(src_bounds_lat, ...)

Compute overlap area between two spherical polygon cells that are defined by their bounds

is_point_on_edge(p1, p2, q)

Check if point q is on the inside of the edge defined by p1->p2.

point_in_polygon(x, y, poly)

Test if a point is inside a polygon, with the ray casting algorithm

points_in_polygon(x, y, poly)

Test if points are inside a polygon

quick_overlap_check(src_lats, src_lons, ...)

Quick bounding box check to eliminate obviously non-overlapping cells.

spherical_area(lats, lons)

Calculate a polygon area in spherical coordinates

unwrap_longitudes(lons, ref)

Make the longitudes of a polygon continuous, in the 180° range around a reference