Repository navigation
Description
Before you start
- I searched the existing issues and did not find a duplicate.
- This is a bug report, not a usage question (questions belong in Discussions).
What happened?
A polygon whose ring loops around a pole without being cut at ±180° drops out of the geometry tools. For a cap above 80°N written as the 12-point loop in Steps to reproduce (every 30° at 80°N), on main (8ebc4ce) and on #1349's branch:
- Spatial Join finds no points in it, not even one at 85°N;
- Clip keeps none of those points;
- Feature To Point puts its point on the ring, at (75°E, 80°N);
- Tabulate Intersection's map area for it is 0.
The ground measures do see a cap, but disagree on which (#1353). Only Tabulate Intersection says anything, and it calls the loop an antimeridian crossing that wasn't split; the other tools say nothing.
The tools read longitude and latitude as x and y, as OGC Simple Features does, and every vertex of this ring has y = 80, so it's collinear: a zero-area polygon. #1033 settled the form RustGIS uses for polygons around a pole: cut at ±180° and closed along the pole, as GDAL's antimeridian wrapping and Natural Earth write them (RFC 7946 §3.1.9 asks only for cutting at ±180°). With #1347–#1349 that form works near the pole; a loop doesn't. Loops come from PostGIS geography columns, which RustGIS reads with a cast to geometry (crates/data/src/source/postgis.rs), and from GeoJSON whose writer didn't cut at ±180°.
Steps to reproduce
- Save
loop.geojson:{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"name":"loop"},"geometry":{"type":"Polygon","coordinates":[[[0,80],[30,80],[60,80],[90,80],[120,80],[150,80],[180,80],[210,80],[240,80],[270,80],[300,80],[330,80],[0,80]]]}}]}andpts.geojson:{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"name":"p"},"geometry":{"type":"Point","coordinates":[45,85]}}]} - Run:
It prints "Spatial Join: 1 features joined (0 matches)" and "Clip: 0 features kept", with no notice about the loop.
rustgis-cli run --data loop.geojson --data pts.geojson \ --cmd 'gp.run={"tool":"spatialJoin","params":{"target":"pts","join":"loop","match":"Intersects","output":"joined"}}' \ --cmd 'gp.run={"tool":"clip","params":{"input":"pts","clip":"loop","output":"clipped"}}'
Expected behavior
At the least, the tools report such rings, with a count, rather than treat them as empty. How to read them needs a decision:
- Where: rewrite loops into the canonical form on read, with a notice giving the count (the data changes, so an export no longer writes the loop back as it was read), or only for analysis and the measures (the data stays as written, but the map still draws a loop as a line).
- Which side: the smaller by default (BigQuery's default), and the side on the left of the direction of travel only where the source asserts it (GeoParquet's
orientation, SQL Server's left-hand rule). RFC 7946 §3.1.6 asks for counterclockwise outer rings but tells parsers not to reject other windings, and much data is wound the other way. A ring whose two sides are within 1% of half the Earth gets reported. - Its edges: the canonical form assumes edges straight in longitude and latitude. Read as great circles, as a
geographycolumn means them, the 12-point loop is a 12-gon whose edges bulge 37 km poleward, 3.736 M km² rather than the parallel's 3.909 M km², so rewriting it means adding vertices along those arcs first. Which reading applies is a wider question (issue to follow).
Detecting a loop: a ring with a vertex at a pole reaches the pole and isn't a loop. For the rest, fold each step of longitude into (-180°, 180°], keeping steps of exactly ±360° as written; a total of ±360° is one turn around a pole, ±720° two.
Tests: loops around each pole, both windings, from 0° and from -180°, with a hole, in a multipolygon, winding twice, with a coordinate missing, each giving the same results as the canonical form. The Apache-2.0 Python antimeridian package is a reference for the algorithm.
How are you running RustGIS?
Command line (rustgis-cli)
Version
main at 8ebc4ce, built from source, and #1349's branch
Operating system, browser and graphics
macOS (Apple silicon)
Sample data
The files in the steps above. I'm raising this for a decision first, and can implement whichever way is chosen.
Activity
flight1973 commentedon Nov 14, 2026
I'm taking the first part: the tools say when a ring loops around a pole, with a count, instead of treating it as empty. No data changes, so it doesn't depend on the decision below.
For the rewrite itself, my suggestion is:
orientation, SQL Server's left-hand rule). Rings within 1% of half the Earth get reported.geographyarcs can come with the wider question.If that works for you, I'll do the rewrite as a second pull request once the reporting one is in.
fix(analysis): a polygon looping around a pole is said, not dropped w…
flight1973 commentedon Nov 17, 2026
@giswqs the reporting half is in (#2088). Before I start the rewrite, do the defaults above work for you? The main one is which side: the smaller one unless the source says otherwise, which I think fits with how #1666 refuses ambiguous areas. Happy to adjust before I write it.
flight1973 commentedon Nov 17, 2026
One more thing before you answer: your tests from #1632 already pick a side for these rings.
wgs84_rings_keep_full_turn_edges_and_large_areasexpects a ring of 36 points along 60° N to measure the southern cap, more than half the Earth, andwgs84_near_hemisphere_rings_keep_the_spherical_sidedoes the same just north and south of the equator. So today a loop along 66.5° N measures everything but the Arctic, while the same loop along 66.5° S measures the Antarctic.The smaller side would change those two tests. I have it working locally (the Arctic and Antarctic loops give the same cap, and a loop within 1% of half the Earth is refused like #1666's rings), but I won't open it unless that's the rule you want. If you'd rather keep the south side, I'll build the analysis half to match it instead.