Skip to content

Commit b6a238a

Browse files
Regenerate notebooks and solutions
1 parent c6a9e4d commit b6a238a

11 files changed

Lines changed: 108 additions & 58 deletions

notebooks/01-introduction-tabular-data.ipynb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
"editable": true
429429
},
430430
"source": [
431-
"Pandas provides a large set of **summary** functions that operate on different kinds of pandas objects (DataFrames, Series, Index) and produce single value. When applied to a DataFrame, the result is returned as a pandas Series (one value for each column). "
431+
"Pandas provides a large set of **summary** functions that operate on different kinds of pandas objects (DataFrames, Series, Index) and produce a single value. When applied to a DataFrame, the result is returned as a pandas Series (one value for each column). "
432432
]
433433
},
434434
{
@@ -832,7 +832,7 @@
832832
"\\> | Greater than\n",
833833
"\\>= | Greater than or equal\n",
834834
"< | Lesser than\n",
835-
"!= | Lesser than or equal\n",
835+
"<= | Lesser than or equal\n",
836836
"\n",
837837
"and to combine multiple conditions:\n",
838838
"\n",
@@ -958,7 +958,7 @@
958958
"\n",
959959
"**EXERCISE**:\n",
960960
"\n",
961-
"* What is the average popolation number of the districts?\n",
961+
"* What is the average population number of the districts?\n",
962962
"* And what is the median?\n",
963963
"\n",
964964
"<details>\n",
@@ -1241,7 +1241,7 @@
12411241
"\n",
12421242
"**EXERCISE**:\n",
12431243
"\n",
1244-
"* Select all rows for the districts of the 1st arrondissement.\n",
1244+
"* Select all rows for the districts of the 3rd arrondissement.\n",
12451245
"* For this subset, what is the total population of the arrondissement?\n",
12461246
" \n",
12471247
"</div>"
@@ -1669,7 +1669,7 @@
16691669
"editable": true
16701670
},
16711671
"source": [
1672-
"This is only an ultra short intro to matplotlib. In the course materials, you can find another notebook with some more details ([visualization_01_matplotlib.ipynb](visualization_01_matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements))."
1672+
"This is only an ultra short intro to matplotlib. In the course materials, you can find another notebook with some more details ([visualization-01-matplotlib.ipynb](visualization_01_matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements))."
16731673
]
16741674
},
16751675
{
@@ -1685,7 +1685,7 @@
16851685
"\n",
16861686
"Galleries are great to get inspiration, see the plot you want, and check the code how it is created:\n",
16871687
" \n",
1688-
"* [matplotlib gallery](http://matplotlib.org/gallery.html\") is an important resource to start from\n",
1688+
"* [matplotlib gallery](http://matplotlib.org/gallery.html) is an important resource to start from\n",
16891689
"* [seaborn gallery](https://seaborn.pydata.org/examples/index.html)\n",
16901690
"* The Python Graph Gallery (https://python-graph-gallery.com/)\n",
16911691
"\n",

notebooks/02-introduction-geospatial-data.ipynb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
},
6464
"outputs": [],
6565
"source": [
66-
"countries = geopandas.read_file(\"zip://./data/ne_110m_admin_0_countries.zip\")\n",
66+
"countries = geopandas.read_file(\"data/ne_110m_admin_0_countries.zip\")\n",
6767
"# or if the archive is unpacked:\n",
6868
"# countries = geopandas.read_file(\"data/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp\")"
6969
]
@@ -351,7 +351,7 @@
351351
},
352352
"outputs": [],
353353
"source": [
354-
"cities = geopandas.read_file(\"zip://./data/ne_110m_populated_places.zip\")"
354+
"cities = geopandas.read_file(\"data/ne_110m_populated_places.zip\")"
355355
]
356356
},
357357
{
@@ -388,7 +388,7 @@
388388
},
389389
"outputs": [],
390390
"source": [
391-
"rivers = geopandas.read_file(\"zip://./data/ne_50m_rivers_lake_centerlines.zip\")"
391+
"rivers = geopandas.read_file(\"data/ne_50m_rivers_lake_centerlines.zip\")"
392392
]
393393
},
394394
{
@@ -625,7 +625,7 @@
625625
"<details><summary>Hints</summary>\n",
626626
"\n",
627627
"* Use `type(..)` to check any Python object type\n",
628-
"* The geopandas.read_file() function can read different geospatial file formats. You pass the file name as first argument.\n",
628+
"* The `geopandas.read_file()` function can read different geospatial file formats. You pass the file name as first argument.\n",
629629
"* Use the `.shape` attribute to get the number of features\n",
630630
"\n",
631631
"</details>\n",
@@ -1235,7 +1235,14 @@
12351235
"name": "python",
12361236
"nbconvert_exporter": "python",
12371237
"pygments_lexer": "ipython3",
1238-
"version": "3.8.5"
1238+
"version": "3.8.10"
1239+
},
1240+
"widgets": {
1241+
"application/vnd.jupyter.widget-state+json": {
1242+
"state": {},
1243+
"version_major": 2,
1244+
"version_minor": 0
1245+
}
12391246
}
12401247
},
12411248
"nbformat": 4,

notebooks/03-coordinate-reference-systems.ipynb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@
4242
},
4343
"outputs": [],
4444
"source": [
45-
"countries = geopandas.read_file(\"zip://./data/ne_110m_admin_0_countries.zip\")\n",
46-
"cities = geopandas.read_file(\"zip://./data/ne_110m_populated_places.zip\")\n",
47-
"rivers = geopandas.read_file(\"zip://./data/ne_50m_rivers_lake_centerlines.zip\")"
45+
"countries = geopandas.read_file(\"data/ne_110m_admin_0_countries.zip\")\n",
46+
"cities = geopandas.read_file(\"data/ne_110m_populated_places.zip\")\n",
47+
"rivers = geopandas.read_file(\"data/ne_50m_rivers_lake_centerlines.zip\")"
4848
]
4949
},
5050
{
@@ -259,7 +259,7 @@
259259
},
260260
"outputs": [],
261261
"source": [
262-
"countries_mercator = countries.to_crs(epsg=3395) # or .to_crs({'init': 'epsg:3395'})"
262+
"countries_mercator = countries.to_crs(epsg=3395) # or .to_crs(\"EPSG:3395\")"
263263
]
264264
},
265265
{
@@ -315,7 +315,7 @@
315315
"\n",
316316
"**ATTENTION:**\n",
317317
"\n",
318-
"All the calculations that happen in geopandas and shapely assume that your data is in a 2D cartesian plane, and thus the result of those calculations will only be correct if your data is properly projected.\n",
318+
"All the calculations that happen in GeoPandas and Shapely assume that your data is in a 2D cartesian plane, and thus the result of those calculations will only be correct if your data is properly projected.\n",
319319
"\n",
320320
"</div>"
321321
]
@@ -590,7 +590,14 @@
590590
"name": "python",
591591
"nbconvert_exporter": "python",
592592
"pygments_lexer": "ipython3",
593-
"version": "3.8.5"
593+
"version": "3.8.10"
594+
},
595+
"widgets": {
596+
"application/vnd.jupyter.widget-state+json": {
597+
"state": {},
598+
"version_major": 2,
599+
"version_minor": 0
600+
}
594601
}
595602
},
596603
"nbformat": 4,

notebooks/04-spatial-relationships-joins.ipynb

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"metadata": {},
3434
"outputs": [],
3535
"source": [
36-
"countries = geopandas.read_file(\"zip://./data/ne_110m_admin_0_countries.zip\")\n",
37-
"cities = geopandas.read_file(\"zip://./data/ne_110m_populated_places.zip\")\n",
38-
"rivers = geopandas.read_file(\"zip://./data/ne_50m_rivers_lake_centerlines.zip\")"
36+
"countries = geopandas.read_file(\"data/ne_110m_admin_0_countries.zip\")\n",
37+
"cities = geopandas.read_file(\"data/ne_110m_populated_places.zip\")\n",
38+
"rivers = geopandas.read_file(\"data/ne_50m_rivers_lake_centerlines.zip\")"
3939
]
4040
},
4141
{
@@ -555,10 +555,13 @@
555555
"metadata": {},
556556
"outputs": [],
557557
"source": [
558-
"# Make a plot of the close-by restaurants\n",
559-
"ax = stations_eiffel.to_crs(epsg=3857).plot()\n",
560-
"geopandas.GeoSeries([eiffel_tower], crs='EPSG:2154').to_crs(epsg=3857).plot(ax=ax, color='red')\n",
558+
"# Make a plot of the close-by bike stations\n",
559+
"import matplotlib.pyplot as plt\n",
561560
"import contextily\n",
561+
"\n",
562+
"fig, ax = plt.subplots(figsize=(8, 8))\n",
563+
"stations_eiffel.to_crs(epsg=3857).plot(ax=ax)\n",
564+
"geopandas.GeoSeries([eiffel_tower], crs='EPSG:2154').to_crs(epsg=3857).plot(ax=ax, color='red')\n",
562565
"contextily.add_basemap(ax)\n",
563566
"ax.set_axis_off()"
564567
]
@@ -733,7 +736,7 @@
733736
"## Spatial join operation\n",
734737
"\n",
735738
"<div class=\"alert alert-info\" style=\"font-size:120%\">\n",
736-
" \n",
739+
"\n",
737740
"**SPATIAL JOIN** = *transferring attributes from one layer to another based on their spatial relationship* <br>\n",
738741
"\n",
739742
"\n",
@@ -781,6 +784,15 @@
781784
"joined"
782785
]
783786
},
787+
{
788+
"cell_type": "code",
789+
"execution_count": null,
790+
"metadata": {},
791+
"outputs": [],
792+
"source": [
793+
"joined[joined[\"name_right\"] == \"France\"]"
794+
]
795+
},
784796
{
785797
"cell_type": "code",
786798
"execution_count": null,
@@ -1055,7 +1067,14 @@
10551067
"name": "python",
10561068
"nbconvert_exporter": "python",
10571069
"pygments_lexer": "ipython3",
1058-
"version": "3.8.5"
1070+
"version": "3.8.10"
1071+
},
1072+
"widgets": {
1073+
"application/vnd.jupyter.widget-state+json": {
1074+
"state": {},
1075+
"version_major": 2,
1076+
"version_minor": 0
1077+
}
10591078
}
10601079
},
10611080
"nbformat": 4,

notebooks/05-spatial-operations-overlays.ipynb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@
420420
"\n",
421421
"GeoPandas (and Shapely for the individual objects) provide a whole lot of basic methods to analyze the geospatial data (distance, length, centroid, boundary, convex_hull, simplify, transform, ....), much more than what we can touch in this tutorial.\n",
422422
"\n",
423-
"* An overview of all methods provided by GeoPandas can be found here: https://geopandas.readthedocs.io/en/latest/docs/reference.html\n",
423+
"An overview of all methods provided by GeoPandas can be found here: https://geopandas.readthedocs.io/en/latest/docs/reference.html\n",
424424
"\n",
425425
"\n",
426426
"</div>\n",
@@ -713,7 +713,7 @@
713713
},
714714
"outputs": [],
715715
"source": [
716-
"land_use = geopandas.read_file(\"zip://./data/paris_land_use.zip\")\n",
716+
"land_use = geopandas.read_file(\"data/paris_land_use.zip\")\n",
717717
"districts = geopandas.read_file(\"data/paris_districts.geojson\").to_crs(land_use.crs)"
718718
]
719719
},
@@ -833,7 +833,7 @@
833833
},
834834
"outputs": [],
835835
"source": [
836-
"land_use = geopandas.read_file(\"zip://./data/paris_land_use.zip\")\n",
836+
"land_use = geopandas.read_file(\"data/paris_land_use.zip\")\n",
837837
"districts = geopandas.read_file(\"data/paris_districts.geojson\").to_crs(land_use.crs)\n",
838838
"muette = districts[districts.district_name == 'Muette'].geometry.item()"
839839
]
@@ -1290,7 +1290,7 @@
12901290
},
12911291
"outputs": [],
12921292
"source": [
1293-
"land_use = geopandas.read_file(\"zip://./data/paris_land_use.zip\")\n",
1293+
"land_use = geopandas.read_file(\"data/paris_land_use.zip\")\n",
12941294
"districts = geopandas.read_file(\"data/paris_districts.geojson\").to_crs(land_use.crs)"
12951295
]
12961296
},
@@ -1575,7 +1575,14 @@
15751575
"name": "python",
15761576
"nbconvert_exporter": "python",
15771577
"pygments_lexer": "ipython3",
1578-
"version": "3.8.5"
1578+
"version": "3.8.10"
1579+
},
1580+
"widgets": {
1581+
"application/vnd.jupyter.widget-state+json": {
1582+
"state": {},
1583+
"version_major": 2,
1584+
"version_minor": 0
1585+
}
15791586
}
15801587
},
15811588
"nbformat": 4,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print("I am a part of the solution!!")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Convert to the Web Mercator projection
2-
stations_webmercator = stations.to_crs(epsg=3857)
2+
stations_webmercator = stations.to_crs("EPSG:3857")
33
stations.head()
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Filter the restaurants for closer than 1 km
1+
# Filter the bike stations closer than 1 km
22
stations_eiffel = stations[dist_eiffel < 1000]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Import the land use dataset
2-
land_use = geopandas.read_file("zip://./data/paris_land_use.zip")
2+
land_use = geopandas.read_file("data/paris_land_use.zip")
33
land_use.head()

notebooks/_solutions/case-curieuzeneuzen-air-quality42.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
frequent_categories = counts[counts > 50].index
66
classes = [value for value in classes if value in frequent_categories]
77

8-
fig, ax = plt.subplots(figsize=(10, 10))
8+
fig, ax = plt.subplots(figsize=(10, 8))
99
seaborn.boxplot(y="land_use_class", x="no2", data=subset, ax=ax, color="C0", order=classes)
1010
ax.set(xlabel="NO$_2$ concentration (µg/m³)", ylabel="CORINE Land Cover classes");

0 commit comments

Comments
 (0)