Skip to content

Conversation

@SamuelTrahanNOAA
Copy link

@SamuelTrahanNOAA SamuelTrahanNOAA commented Jan 28, 2026

Description

Filters observations that are outside of a polygon on the sphere. Supports convex and concave polygons, including dateline-crossing, pole-crossing, and polygons that span more than half the sphere. It has been tested with a full domain boundary containing about twelve thousand vertices, and with polygons as small as three vertices.

The implementation uses boost::geometry::within, in the cs::geographic coordinate system. Calculations are done in double precision with degrees.

Note that, like all template-heavy calculations, automatic inlining is critical for performance. With GCC, I saw a factor of 20 difference in performance of boost::geometry::within between inlining and non-inlining compilation. This won't matter for small polygons and a few observations, but it'll matter for a full domain boundary and many thousands of observations.

Example:

 - &POLY
   filter: Polygon Check
   inside point longitude: -90
   inside point latitude: 42
   vertex longitudes: [ -110, -100, -80, -90, -95, -110 ]
   vertex latitudes: [ 30, 45, 40, 25, 35, 30 ]
   action:
     name: reduce obs space

The inside point determines which side of the polygon is inside. Vertex longitudes and latitudes specify the polygon.

All points outside the polygon are flagged. Hence, in this example, all observations outside the polygon will be removed from the obs space.

The behavior at the exact polygon boundary will be inconsistent, so it is best to expand the polygon if you want the edges to be included.

Issue(s) addressed

No issues have been submitted; this development came about due to internal discussions.

Dependencies

None

Impact

None

Checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation --There's a PR open to update the documentation.
  • I have run the unit tests before creating the PR -- The unit tests will not run on the NOAA GAEA machine; they hang even without my changes. There is a unit test of this filter, and that one works.

@BenjaminRuston
Copy link
Contributor

@SamuelTrahanNOAA great! thanks Samuel

this is in public JCSDA and would need to be brought into internal, I can do this on your behalf.

Also would make sense to add a ctest possibly, and just leverage another existing ctest. If it's brought in would it make sense that this is something to pass along to @guoqing-noaa (adding the ctest)

@SamuelTrahanNOAA
Copy link
Author

It needs a ctest, but the ctests won't run on the machine I've been using for development. I'm moving to another machine that might be able to run the ctests. Once I can run ctests, I'll add one for this filter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants