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

Add osm-flex to CLIMADA core #981

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open

Conversation

luseverin
Copy link
Collaborator

@luseverin luseverin commented Dec 2, 2024

Changes proposed in this PR:

  • Add osm-flex to the requirements
  • Add section in exposure_polygons_lines tutorial to show how to obtain exposure data from OpenStreetMap using osm-flex

Comments:
Adding the osm-flex package to the dependencies does not seem to create any conflicts. I then modified the tutorial Exposures_polygons_lines (https://climada-python.readthedocs.io/en/stable/tutorial/climada_entity_Exposures_polygons_lines.html) to briefly show how to use osm-flex to retrieve data. This is the main part of the review.

PR Author Checklist

PR Reviewer Checklist

@luseverin luseverin requested review from chahank and Evelyn-M December 2, 2024 10:58
@chahank
Copy link
Member

chahank commented Dec 2, 2024

Nice! I see that the Unit test are currently failing. The error message is however empty, so maybe this is related to this PR, or maybe not. It would be good to check to be sure.

Copy link
Member

@chahank chahank left a comment

Choose a reason for hiding this comment

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

Excellent addition!

I would however separate the OSM examples into a separate tutorial that would also be directly visible as sub-element of the Exposures tutorials. I think this would be cleaner. Otherwise, it is quite hard to find.

I would then also add a final example of an impact calculation with the obtained OSM features. The extraction of points, lines and polygons is already documented in the OSMflex documentation, so we do not have to duplicate it too much. But how to make an exposure out of the elements and then the impact is useful.

@luseverin
Copy link
Collaborator Author

Thanks for the feedback! I put the retrieval of exposure data from OSM + a simple impact calculation in a separate tutorial and added a small mention to this new tuto at the begininng of the polygons_lines tutorial.

Regarding the failing tests, something weird was happening (tests were getting cancelled for no apparent reason), but it looks all good now.

@luseverin luseverin requested a review from chahank December 3, 2024 11:02
@chahank
Copy link
Member

chahank commented Dec 3, 2024

At the moment the tutorial has 53,393 changes (!). Please reduce this to only the relevant information. At the moment it is not even possible to make comments on the tutorial due to the large number of changes ;)

@chahank
Copy link
Member

chahank commented Dec 3, 2024

I would have some comments on the phrasing. I think the beginning is a bit unclear for new users.

Also, I would make sure that the impact computation at the shows some impact. At the moment it looks like there is 0 impact.

@chahank
Copy link
Member

chahank commented Dec 3, 2024

I also do not really understand the example the impact example. The goal is not to copy the lines polygon tutorial, but to have an example of using OSM data. Ideally, this is the first thing on top of the tutorial.

@luseverin
Copy link
Collaborator Author

Basically, what I have put in the tutorial is:

  1. Examples of loading OSM data using osm-flex: roads as lines and forests as polygons for the netherlands
  2. Setting up of the road and forest OSM exposure data as CLIMADA exposure object
  3. Example of calculation of the impact on the roads and forests using winter storms as hazard

Would you suggest I put more emphasis on 3.? But in the end we still need to load the data from OSM at some point (but I could try to make this part shorter e.g. remove the plots). Let me know!

@chahank
Copy link
Member

chahank commented Dec 3, 2024

Yes, I would just make a very quick example to show that it can be used for impact computations (exposure comes from OSM, one needs to assign values), and then the details for the the roads and the forests.

Maybe also include a link to the OSM tags (all the things that can be downloaded). Maybe also add a note that if things don't work with OSMflex one should first look in the documentation there.

@chahank
Copy link
Member

chahank commented Dec 6, 2024

Do you need help to sanitize the files? (there should not be 53000 new lines for this PR)

@luseverin
Copy link
Collaborator Author

No I do not need help for that, I was just thinking of how to reorganize the tuto. Now I added a quick example at the start, is that good enough? Should I still add more detailed examples in the next sections e.g. using other osm layers or assigning values using LitPop?

PS: I now also need to fix this weird error in the u_lp.plot_eai_exp_geom(impact); : ValueError: Length of values (861875) does not match length of index (861881)

@chahank
Copy link
Member

chahank commented Dec 9, 2024

Super nice! I would suggest the following fine-tuning:

1- correct some of the typos (e.g., Honduras -> Netherlands)
2- Make in the first example clear what the implicit value is. Now you decided to put the value 1e5 per 500m of lines.
3- Avoid using capitalized variables unless they are meant to be global constants (which e.g., IMPF_LINE are not. There are more in the tutorial.)
4- At the end, explain well how to go from OSM inputs to an exposure with values
5- Add an example of OSM with points
6- Speak of osm-flex as a python package, not a module
7- Remove unecessary code (e.g., in the all of import osm_flex.download import osm_flex.extract import osm_flex.clip import osm_flex.simplify are not needed in the first cell. There are more in the tutorial I think.)
8- I think the whole section How to compute impacts using polygons or lines as exposure in CLIMADA can be removed. Instead, clearly link to the tutorial on that. I think the goal of this tutorial is to show how to make an exposures from OSM-flex. So, it is not about reproducing the OSM-flex tutorials, not to reproduce the lines-polygons tutorial for impacts, but how to make exposures from OSM with OSM-flex in CLIMADA.
9- Maybe show an example with clip and simplify?
10- Do you need the import logging from climada.util.config import LOGGER LOGGER.setLevel(logging.ERROR)?

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.

2 participants