From b72a61b30a6e7f442ef4d3e1467f89e66c713713 Mon Sep 17 00:00:00 2001 From: David Hoese Date: Thu, 20 Jun 2024 15:39:32 -0500 Subject: [PATCH] Workaround swaths crossing the anti-meridian causing negative coverage percentages --- polar2grid/filters/_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/polar2grid/filters/_utils.py b/polar2grid/filters/_utils.py index 682e6098..3e9d0326 100644 --- a/polar2grid/filters/_utils.py +++ b/polar2grid/filters/_utils.py @@ -53,6 +53,9 @@ def boundary_for_area(area_def: PRGeometry) -> Boundary: try: adp = area_def.boundary() adp.decimate(int(freq_fraction * area_def.shape[0])) + if adp.contour_poly.area() < 0: + # https://github.com/ssec/polar2grid/issues/696 + raise ValueError("Failed to generate valid polygon for area. Polygon has a negative area.") except ValueError: if not isinstance(area_def, SwathDefinition): logger.error("Unable to generate bounding geolocation polygon")