-
Notifications
You must be signed in to change notification settings - Fork 102
Densify the geostationary bounding polygon before reprojecting in AreaSlicer #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lorenzo-cingano
wants to merge
1
commit into
pytroll:main
Choose a base branch
from
lorenzo-cingano:fix_partial_geostationary_disk_slicing
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -175,7 +175,18 @@ def get_polygon_to_contain(self): | |
| x, y = self.area_to_contain.get_edge_lonlats(vertices_per_side=10) | ||
| if self.area_to_crop.is_geostationary: | ||
| x_geos, y_geos = get_geostationary_bounding_box_in_proj_coords(self.area_to_crop, 360) | ||
| x_geos, y_geos = self._source_transformer.transform(x_geos, y_geos, direction=TransformDirection.INVERSE) | ||
| geos_poly = Polygon(zip(x_geos, y_geos, strict=True)) | ||
| # Densify the polygon before reprojecting it to the destination crs. | ||
| # Clipping a partial disk (for example rapid scan or region of interest | ||
| # data) to its area extent introduces straight chord edges. Those chords | ||
| # are not straight in the destination crs, so without intermediate | ||
| # vertices the reprojected polygon cuts the corner and the computed slice | ||
| # is too small, leaving part of the destination without data. | ||
| segment_length = np.max(np.abs(self.area_to_crop.area_extent)) / 100 | ||
| geos_poly = geos_poly.segmentize(segment_length) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| x_geos, y_geos = geos_poly.exterior.coords.xy | ||
| x_geos, y_geos = self._source_transformer.transform( | ||
| np.asarray(x_geos), np.asarray(y_geos), direction=TransformDirection.INVERSE) | ||
| geos_poly = Polygon(zip(x_geos, y_geos, strict=True)) | ||
| poly = Polygon(zip(x, y, strict=True)) | ||
| poly = poly.intersection(geos_poly) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
area_extentis degenerate (e.g. all zeros),segment_lengthbecomes 0 andsegmentize(0)raisesGEOSException: Tolerance must be positive(verified against shapely 2.1.2). Aif segment_length > 0:guard (ormax(segment_length, 1e-9)) would make this robust. Also: with the 1/100 divisor, a very small partial-disk extent produces a fine mesh — worth a sanity bound if performance matters.