Skip to content
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

Bugfix/get geometries extent antimeridian #524

Merged
merged 11 commits into from
Aug 5, 2022

Conversation

bguillod
Copy link
Collaborator

@bguillod bguillod commented Jul 29, 2022

Changes proposed in this PR:

  • Ensure climada.util.coordinates.get_land_geometry deals correctly with extent. Previously, if an extent going beyond [-180, +180] range in longitude the geometry would be cut (e.g. passing extent=(160, 200, -50,50) would actually return the land geometry only for the extent (160, 180, -50, 50).
  • Apply the same correction to get_country_geometry.
  • Removes the redundancy between these two functions by using the latter in the former.
  • Adjust function coord_on_land to ensure longitude coordinates are also properly dealt with.

This PR fixes issue #495.

A first test has been implemented but this can be completed.

Pull Request Checklist

  • Correct target branch selected (if unsure, select develop)
  • Source branch up-to-date with target branch
  • Docs updated
  • Tests updated
  • Tests passing
  • No new linter issues

@bguillod
Copy link
Collaborator Author

Working on fixing the failed checks...

@bguillod
Copy link
Collaborator Author

Ok so one last test is still failing: test_get_land_geometry_country_pass.

It looks as if the PR slightly changed the extent of some countries used in this test. I think this might be due to the fact that the filtering of the shapes in natural earth has been slightly adjusted within this PR.

Does anybody know who wrote these tests?

In my opinion we can update the expected value of these tests, so they pass. However I need someone else's opinion to confirm as I don't want to oversee something that also could be an issue.

@tovogt tovogt force-pushed the bugfix/get-geometries-extent-antimeridian branch from ed63394 to a4344d8 Compare August 3, 2022 14:21
@tovogt
Copy link
Collaborator

tovogt commented Aug 3, 2022

From my perspective, this is ready to be merged. I just added some code clean-up for the linter, but the rest is fine.

Ok so one last test is still failing: test_get_land_geometry_country_pass.

It looks as if the PR slightly changed the extent of some countries used in this test. I think this might be due to the fact that the filtering of the shapes in natural earth has been slightly adjusted within this PR.

Does anybody know who wrote these tests?

In my opinion we can update the expected value of these tests, so they pass. However I need someone else's opinion to confirm as I don't want to oversee something that also could be an issue.

The tests were "broken" from the start because they passed the keyword arguments as positional arguments and the result was that the 110 (which was obviously supposed to be the resolution) was actually assigned to the extent keyword argument, so that the actual resolution used was 10 (the default value of that keyword argument). I fixed this by explicitly selecting 10 as the resolution.

@emanuel-schmid
Copy link
Collaborator

🙌

@emanuel-schmid emanuel-schmid merged commit eed7058 into develop Aug 5, 2022
@emanuel-schmid emanuel-schmid deleted the bugfix/get-geometries-extent-antimeridian branch August 5, 2022 10:01
mmyrte pushed a commit that referenced this pull request Aug 5, 2022
mmyrte added a commit that referenced this pull request Aug 5, 2022
* Ensure get_country_geometries deals correctly with extent crossing the anti-meridian

* get_land_gemoetry to rely on get_country_geometries to avoid redundancies

* Ensure coord_on_land properly deals with extent of land_geom and lon

* Adding a simple unit test for coord_on_land with points beyond the anti-meridian

* Fix in case land_geom is empty (no land within extent)

* provide keyword arg in unit test test_get_land_geometry_country_pass

* u_coord: some refactoring and linting

* u_coord: fix tests for get_land_geometry

* coordinates: shapely.geometry.Polygon still referenced
in `points_to_raster`

* test_coordinates: complementary testcases for get_country_geometries

Co-authored-by: Thomas Vogt <[email protected]>
Co-authored-by: emanuel-schmid <[email protected]>
mmyrte added a commit that referenced this pull request Aug 5, 2022
@bguillod
Copy link
Collaborator Author

bguillod commented Aug 8, 2022

Thanks a lot @tovogt and @emanuel-schmid for reviewing and merging!

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.

3 participants