Package pygeodesy :: Module clipy |
[frames] | no frames]

# Module clipy

Clip a path or polygon.

Clip a path or polygon of `LatLon` points against a rectangular box or a (convex) clip region.

Version: 21.10.23

Classes
| ClipError Clip box or clip region issue.
| ClipCS4Tuple 4-Tuple `(start, end, i, j)` for each edge of a clipped path with the `start` and `end` points (`LatLon`) of the portion of the edge inside or on the clip box and the indices `i` and `j` (`int`) of the edge start and end points in the original path.
| ClipLB6Tuple 6-Tuple `(start, end, i, fi, fj, j)` for each edge of the clipped path with the `start` and `end` points (`LatLon`) of the portion of the edge inside or on the clip box, indices `i` and `j` (both `int`) of the original path edge start and end points and fractional indices `fi` and `fj` (both FIx) of the `start` and `end` points along the edge of the original path.
| ClipSH3Tuple 3-Tuple `(start, end, original)` for each edge of a clipped polygon, the `start` and `end` points (`LatLon`) of the portion of the edge inside or on the clip region and `original` indicates whether the edge is part of the original polygon or part of the clip region (`bool`).

Functions
clipCS4(points, lowerleft, upperright, closed=False, inull=False) Clip a path against a rectangular clip box using the Cohen-Sutherland algorithm. |
clipLB6(points, lowerleft, upperright, closed=False, inull=False) Clip a path against a rectangular clip box using the Liang-Barsky algorithm. |
clipSH(points, corners, closed=False, inull=False) Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. |
clipSH3(points, corners, closed=False, inull=False) Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. |

Variables
| __all__ = `_ALL_LAZY.clipy`

Function Details

### clipCS4 (points, lowerleft, upperright, closed=False, inull=False) |
Clip a path against a rectangular clip box using the Cohen-Sutherland algorithm. Arguments: `points` - The points (`LatLon`[]). `lowerleft` - Bottom-left corner of the clip box (`LatLon`). `upperright` - Top-right corner of the clip box (`LatLon`). `closed` - Optionally, close the path (`bool`). `inull` - Optionally, retain null edges if inside (`bool`). Returns: Yield a ClipCS4Tuple`(start, end, i, j)` for each edge of the clipped path. Raises: `ClipError` - The `lowerleft` and `upperright` corners specify an invalid clip box. `PointsError` - Insufficient number of `points`.

### clipLB6 (points, lowerleft, upperright, closed=False, inull=False) |
Clip a path against a rectangular clip box using the Liang-Barsky algorithm. Arguments: `points` - The points (`LatLon`[]). `lowerleft` - Bottom-left corner of the clip box (`LatLon`). `upperright` - Top-right corner of the clip box (`LatLon`). `closed` - Optionally, close the path (`bool`). `inull` - Optionally, retain null edges if inside (`bool`). Returns: Yield a ClipLB6Tuple`(start, end, i, fi, fj, j)` for each edge of the clipped path. Raises: `ClipError` - The `lowerleft` and `upperright` corners specify an invalid clip box. `PointsError` - Insufficient number of `points`. See Also: Liang-Barsky Line Clipping, Liang-Barsky line clipping algorithm and Liang-Barsky algorithm.

### clipSH (points, corners, closed=False, inull=False) |
Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. Arguments: `points` - The polygon points (`LatLon`[]). `corners` - Three or more points defining a convex clip region (`LatLon`[]) or two points to specify a rectangular clip box. `closed` - Close the clipped points (`bool`). `inull` - Optionally, include null edges (`bool`). Returns: Yield the clipped points (`LatLon`[]). Raises: `ClipError` - The `corners` specify a polar, zero-area, non-convex or otherwise invalid clip box or region. `PointsError` - Insufficient number of `points`.

### clipSH3 (points, corners, closed=False, inull=False) |
Clip a polygon against a clip region or box using the Sutherland-Hodgman algorithm. Arguments: `points` - The polygon points (`LatLon`[]). `corners` - Three or more points defining a convex clip region (`LatLon`[]) or two points to specify a rectangular clip box. `closed` - Close the clipped points (`bool`). `inull` - Optionally, include null edges (`bool`). Returns: Yield a ClipSH3Tuple`(start, end, original)` for each edge of the clipped polygon. Raises: `ClipError` - The `corners` specify a polar, zero-area, non-convex or otherwise invalid clip box or region. `PointsError` - Insufficient number of `points`.