Avoid `Impact` storing a `pyproj.CRS` object by peanutfun · Pull Request #713 · CLIMADA-project/climada_python
Navigation Menu
{{ message }}
CLIMADA-project / climada_python Public
- Notifications You must be signed in to change notification settings
- Fork 151
Merged
Avoid Impact storing a pyproj.CRS object#713
Avoid Impact storing a pyproj.CRS object#713
Conversation
Copy link
Member
Changes proposed in this PR:
- Transform
pyproj.CRSinto WKT string inImpact.__init__. WKT is the most precise form of storing CRS information, apart from an actualCRSobject. This should work fine as theImpact.crsattribute can now safely be stored as string, and inserting the WKT into theExposuresconstructor is supported. - Fix a subtle bug in an impact test
This PR fixes #706
PR Author Checklist
- Read the Contribution Guide
- Correct target branch selected (if unsure, select
develop) - Descriptive pull request title added
- Source branch up-to-date with target branch
- Documentation updated
- Tests updated
- Tests passing
- No new linter issues
- Changelog updated
PR Reviewer Checklist
- Read the Contribution Guide
- CLIMADA Reviewer Checklist passed
- Tests passing
- No new linter issues
Copy link
Member Author
peanutfun
commented
May 4, 2023
peanutfun commented
May 4, 2023@ChrisFairless could you check if this resolves your issue? Instead of storing CRS objects, I resorted to converting them into WKT strings when passing them to the Impact constructor
peanutfun
added
bugfix
awaiting feedback
labels
Copy link
Collaborator
ChrisFairless
commented
May 9, 2023
ChrisFairless commented
May 9, 2023Yes this looks good! Thanks for the fix.
I like how the WKT is recognised by rasterio.crs.CRS.from_user_input so we can still use this to check CRS equality.
peanutfun
removed
the
awaiting feedback
label
peanutfun
requested review from
chahank and
emanuel-schmid
Copy link
Collaborator
Agreed. In my experience, WKT is the one that gives the least amount of warnings. 😁
I've added the crs to the attributes list so it's clear that it is a string.
- but then ... maybe it's not. What if it's a
rasterio.crs.CRS?
Copy link
Member Author
peanutfun
commented
May 12, 2023
peanutfun commented
May 12, 2023rasterio.crs.CRS supports to_wkt, too: https://rasterio.readthedocs.io/en/latest/api/rasterio.crs.html#rasterio.crs.CRS.to_wkt
I'll patch that.
emanuel-schmid and others added 3 commits
May 12, 2023 17:34Copy link
Member Author
peanutfun
commented
May 12, 2023
peanutfun commented
May 12, 2023@emanuel-schmid Fixed handling of rasterio.crs.CRS here: a5ab8bd
emanuel-schmid added 2 commits
May 15, 2023 13:17Copy link
Collaborator
emanuel-schmid
commented
May 15, 2023
emanuel-schmid commented
May 15, 2023Many thanks! To me it's fine for merging, I've added a changlog entry. Feel free to edit.
Copy link
Member Author
peanutfun
commented
May 15, 2023
peanutfun commented
May 15, 2023@emanuel-schmid How should we handle the erroneous pylint issue here: https://github.com/CLIMADA-project/climada_python/pull/713/files#diff-1c276908f04d1a0ca5b1692295a586ce54b0937673711203582d3d72099ecdd0R45 ?
Copy link
Collaborator
🤷 I's just suppress it for this particular line by adding # pylint: disable=no-name-in-module at the end.
There are only 2 of this kind throughout climada_python so changing .pylintrc seems over-reacting.
peanutfun
merged commit
57086eb
into
develop
chahank
mentioned this pull request
emanuel-schmid
deleted the
impact-write-crs
branch
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment