Skip to content

Densify the geostationary bounding polygon before reprojecting in AreaSlicer - #729

Merged
djhoese merged 4 commits into
pytroll:mainfrom
lorenzo-cingano:fix_partial_geostationary_disk_slicing
Oct 8, 2026
Merged

djhoese merged 4 commits into
pytroll:mainfrom
lorenzo-cingano:fix_partial_geostationary_disk_slicing

Conversation

@lorenzo-cingano

Copy link
Copy Markdown
Contributor

AreaSlicer.get_polygon_to_contain builds the bounding polygon of a geostationary source disk and reprojects it into the destination projection to compute the source slice. When the source is a partial disk (rapid scan or region of interest data), clipping the disk to its area extent introduces straight chord edges with only two vertices. Those chords are not straight in the destination projection, so the reprojected polygon cuts the corner and the source slice comes out too small, leaving part of the destination empty. A full disk source is unaffected, because its whole boundary is the densely sampled disk arc.

This densifies the polygon with segmentize before reprojecting it, so the chord edges keep enough vertices to follow their true shape in the destination projection. The problem was found in satpy when resampling MSG rapid scan data to a polar stereographic area with gradient_search.

segmentize needs shapely 2.0 or newer. shapely is currently unpinned in the dependencies, so a shapely>=2.0 pin can be added if you want it explicit.

…aSlicer

AreaSlicer.get_polygon_to_contain builds the bounding polygon of a
geostationary source disk and reprojects it into the destination
projection to compute the source slice. When the source is a partial
disk (rapid scan or region of interest data), clipping the disk to its
area extent introduces straight chord edges with only two vertices.
Those chords are not straight in the destination projection, so the
reprojected polygon cuts the corner and the source slice comes out too
small, leaving part of the destination without data.

Densify the polygon with segmentize before reprojecting it, so the chord
edges keep enough vertices to follow their true shape in the destination
projection.
@djhoese

djhoese commented Jul 2, 2026

Copy link
Copy Markdown
Member

Thanks for this PR! I just wanted to let you know that we're not ignoring you, but most of us are on vacation or (like me) don't have time to review this right now. I hope to review it next week though.

@codecov

codecov Bot commented Jul 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.90%. Comparing base (2e7a3c8) to head (1065291).
⚠️ Report is 43 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #729      +/-   ##
==========================================
+ Coverage   93.68%   93.90%   +0.22%     
==========================================
  Files          89       89              
  Lines       13715    13937     +222     
==========================================
+ Hits        12849    13088     +239     
+ Misses        866      849      -17     
Flag Coverage Δ
unittests 93.90% <100.00%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Manny7717 Manny7717 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Verified locally on head 99f9c93c: 19/19 tests in pyresample/test/test_slicer.py pass (shapely 2.1.2). The approach is sound — densifying in the source projection before the inverse transform is exactly where the straight chord edges need intermediate vertices, since chords in the geos projection become curves in the destination CRS.

Two things to look at (inline): a Shapely minimum-version concern for segmentize, and a degenerate-extent crash in the segment_length computation. Both are cheap to guard.

Comment thread pyresample/slicer.py
Comment thread pyresample/slicer.py Outdated
@djhoese djhoese self-assigned this Sep 14, 2026
Comment thread pyresample/slicer.py
Comment thread pyresample/test/test_slicer.py Outdated
@djhoese

djhoese commented Oct 8, 2026

Copy link
Copy Markdown
Member

Thanks for the work on this @lorenzo-cingano. I'm going to merge this now but then borrow your solution in my new #757 PR where it is applied to all area slicing.

@djhoese
djhoese merged commit 7684e06 into pytroll:main Oct 8, 2026
25 of 26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

gradient_search leaves part of the destination empty for a partial geostationary disk

3 participants