Inline exercises for notebooks 1, 2, 3, and 4#15
Conversation
|
@darribas sorry, didn't have time to look at this again. Do we still include it in the material for tomorrow? |
| "source": [ | ||
| "---\n", | ||
| "\n", | ||
| "**Exercise**: Which rivers pass within 1 degree of Paris? And for Hong Kong?\n", |
There was a problem hiding this comment.
I would maybe do it in meters (that's often problem that you need to convert the crs for that)
There was a problem hiding this comment.
I tried first but I ran into issues trying to get a world CRS in metres that worked and the rivers layer was acting up so, for the sake of the example, I left it on degrees.
| "source": [ | ||
| "1. Obtaining a list of European cities\n", | ||
| "1. Creating a `GeoDataFrame` with all river lines\n", | ||
| "1. For every European city, checking whether at least one river \"crosses\" the area within 1 degree\n", |
There was a problem hiding this comment.
Isn't this an exercise for notebook 2 ?
There was a problem hiding this comment.
A list of European cities requires a spatial join. It's a compound exercise.
| " rivers_crossing = river_lines.crosses(buf).sum()\n", | ||
| " if rivers_crossing > 0:\n", | ||
| " answer.append(city)\n", | ||
| "answer = geopandas.GeoDataFrame(answer, \n", |
There was a problem hiding this comment.
I would personally do it with a function and apply. It is maybe more complex in the end, but a good pattern to show IMO.
Or first with loop, and then as exercise to convert it to apply
|
I'd merge and use if time allows |
|
Just so people can access them, can we merge this so the exercises don't get lost on my fork? |
Work in progress but opening for pulling in.