From 835a7ef371280655ed05a1bc4f560f7f23784a5d Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 16 Oct 2025 10:36:00 +0200 Subject: [PATCH 1/3] small fixes --- notebooks/02-introduction-geospatial-data.ipynb | 2 +- notebooks/02-introduction-geospatial-data.md | 2 +- notebooks/04-spatial-relationships-joins.ipynb | 4 ++-- notebooks/04-spatial-relationships-joins.md | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/notebooks/02-introduction-geospatial-data.ipynb b/notebooks/02-introduction-geospatial-data.ipynb index 7275a59..41c5cde 100644 --- a/notebooks/02-introduction-geospatial-data.ipynb +++ b/notebooks/02-introduction-geospatial-data.ipynb @@ -1282,7 +1282,7 @@ "source": [ "A plot with just some points can be hard to interpret without any spatial context. We have seen that we can use the `explore()` method to easily get an interactive figure that by default includes a background map. But also for the static matplotlib-based plot, it can be useful to add such a base map, and that's what we will learn in the next excercise.\n", "\n", - "We are going to make use of the [contextily](https://github.com/darribas/contextily) package. The `add_basemap()` function of this package makes it easy to add a background web map to our plot. We begin by plotting our data first, and then pass the matplotlib axes object (returned by dataframe's `plot()` method) to the `add_basemap()` function. `contextily` will then download the web tiles needed for the geographical extent of your plot.\n", + "We are going to make use of the [contextily](https://contextily.readthedocs.io/en/latest/index.html) package. The `add_basemap()` function of this package makes it easy to add a background web map to our plot. We begin by plotting our data first, and then pass the matplotlib axes object (returned by dataframe's `plot()` method) to the `add_basemap()` function. `contextily` will then download the web tiles needed for the geographical extent of your plot.\n", "\n", "\n", "
\n", diff --git a/notebooks/02-introduction-geospatial-data.md b/notebooks/02-introduction-geospatial-data.md index f992ff5..bf2bcb8 100644 --- a/notebooks/02-introduction-geospatial-data.md +++ b/notebooks/02-introduction-geospatial-data.md @@ -307,7 +307,7 @@ stations.plot(figsize=(12,6)) # or .explore() A plot with just some points can be hard to interpret without any spatial context. We have seen that we can use the `explore()` method to easily get an interactive figure that by default includes a background map. But also for the static matplotlib-based plot, it can be useful to add such a base map, and that's what we will learn in the next excercise. -We are going to make use of the [contextily](https://github.com/darribas/contextily) package. The `add_basemap()` function of this package makes it easy to add a background web map to our plot. We begin by plotting our data first, and then pass the matplotlib axes object (returned by dataframe's `plot()` method) to the `add_basemap()` function. `contextily` will then download the web tiles needed for the geographical extent of your plot. +We are going to make use of the [contextily](https://contextily.readthedocs.io/en/latest/index.html) package. The `add_basemap()` function of this package makes it easy to add a background web map to our plot. We begin by plotting our data first, and then pass the matplotlib axes object (returned by dataframe's `plot()` method) to the `add_basemap()` function. `contextily` will then download the web tiles needed for the geographical extent of your plot.
diff --git a/notebooks/04-spatial-relationships-joins.ipynb b/notebooks/04-spatial-relationships-joins.ipynb index 779c057..047335a 100644 --- a/notebooks/04-spatial-relationships-joins.ipynb +++ b/notebooks/04-spatial-relationships-joins.ipynb @@ -616,8 +616,8 @@ "The location of the Eiffel Tower is: x of 648237.3 and y of 6862271.9\n", "\n", "* Create a Shapely point object with the coordinates of the Eiffel Tower and assign it to a variable called `eiffel_tower`. Print the result.\n", - "* Check if the Eiffel Tower is located within the Montparnasse district (provided).\n", - "* Check if the Montparnasse district contains the bike station location.\n", + "* Check if the Eiffel Tower is located within the Montparnasse district (_code to get the Polygon for Montparnasse is provided_).\n", + "* Check if the Montparnasse district contains the selected bike station location (_code to get the Point for the bike station is provided_).\n", "* Calculate the distance between the Eiffel Tower and the bike station (note: in this case, the distance is returned in meters).\n", "\n", "\n", diff --git a/notebooks/04-spatial-relationships-joins.md b/notebooks/04-spatial-relationships-joins.md index 2847031..96b4d83 100644 --- a/notebooks/04-spatial-relationships-joins.md +++ b/notebooks/04-spatial-relationships-joins.md @@ -183,8 +183,8 @@ The Eiffel Tower is an iron lattice tower built in the 19th century, and is prob The location of the Eiffel Tower is: x of 648237.3 and y of 6862271.9 * Create a Shapely point object with the coordinates of the Eiffel Tower and assign it to a variable called `eiffel_tower`. Print the result. -* Check if the Eiffel Tower is located within the Montparnasse district (provided). -* Check if the Montparnasse district contains the bike station location. +* Check if the Eiffel Tower is located within the Montparnasse district (_code to get the Polygon for Montparnasse is provided_). +* Check if the Montparnasse district contains the selected bike station location (_code to get the Point for the bike station is provided_). * Calculate the distance between the Eiffel Tower and the bike station (note: in this case, the distance is returned in meters). From 6b5fff3bcd30494ed837ea9781711bad631ab2cf Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 16 Oct 2025 14:07:38 +0200 Subject: [PATCH 2/3] lat -51 -> 51 --- notebooks/12-xarray-advanced.ipynb | 8 ++++---- notebooks/12-xarray-advanced.md | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/notebooks/12-xarray-advanced.ipynb b/notebooks/12-xarray-advanced.ipynb index c072a9f..a70018c 100644 --- a/notebooks/12-xarray-advanced.ipynb +++ b/notebooks/12-xarray-advanced.ipynb @@ -1117,9 +1117,9 @@ "\n", "**EXERCISE**:\n", "\n", - "Select the pressure data for the pixel closest to the center of Ghent (lat: -51.05, lon: 3.71) and assign the outcome to a new variable `ghent_pressure`.\n", + "Select the pressure data for the pixel closest to the center of Ghent (lat: 51.05, lon: 3.71) and assign the outcome to a new variable `ghent_pressure`.\n", "\n", - "Define a Matplotlib `Figure` and `Axes` (respectively named `fig, ax`) and use it to create a plot that combines the yearly average of the pressure data in Gent with the monthly pressure data as function of time for that same pixel as line plots. Change the name of the y-label to `'Pressure (Pa)'` and the title of the plot to `'Pressure (Pa) in Ghent (at -51.05, 3.71)'` (see notebook [visualization-01-matplotlib.ipynb](./visualization-01-matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements) for more information)\n", + "Define a Matplotlib `Figure` and `Axes` (respectively named `fig, ax`) and use it to create a plot that combines the yearly average of the pressure data in Gent with the monthly pressure data as function of time for that same pixel as line plots. Change the name of the y-label to `'Pressure (Pa)'` and the title of the plot to `'Pressure (Pa) in Ghent (at 51.05, 3.71)'` (see notebook [visualization-01-matplotlib.ipynb](./visualization-01-matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements) for more information)\n", "\n", "
Hints\n", " \n", @@ -1149,7 +1149,7 @@ "ghent_pressure.resample(time=\"YE\").mean().plot.line(ax=ax)\n", "\n", "ax.set_ylabel('Pressure (Pa)')\n", - "ax.set_title('Pressure (Pa) in Ghent (-51.05, 3.71)')" + "ax.set_title('Pressure (Pa) in Ghent (51.05, 3.71)')" ] }, { @@ -1161,7 +1161,7 @@ "\n", "**EXERCISE**:\n", " \n", - "Select the precipitation data for the pixel closest to the center of Ghent (lat: -51.05, lon: 3.71) and assign the outcome to a new variable `ghent_precipitation`.\n", + "Select the precipitation data for the pixel closest to the center of Ghent (lat: 51.05, lon: 3.71) and assign the outcome to a new variable `ghent_precipitation`.\n", " \n", "For the Ghent pixel, calculate the maximal precipitation _for each month of the year_ (1 -> 12) and convert it to mm precipitation.\n", " \n", diff --git a/notebooks/12-xarray-advanced.md b/notebooks/12-xarray-advanced.md index 036ede1..45a4e64 100644 --- a/notebooks/12-xarray-advanced.md +++ b/notebooks/12-xarray-advanced.md @@ -532,9 +532,9 @@ era5_renamed = era5.rename(mapping) **EXERCISE**: -Select the pressure data for the pixel closest to the center of Ghent (lat: -51.05, lon: 3.71) and assign the outcome to a new variable `ghent_pressure`. +Select the pressure data for the pixel closest to the center of Ghent (lat: 51.05, lon: 3.71) and assign the outcome to a new variable `ghent_pressure`. -Define a Matplotlib `Figure` and `Axes` (respectively named `fig, ax`) and use it to create a plot that combines the yearly average of the pressure data in Gent with the monthly pressure data as function of time for that same pixel as line plots. Change the name of the y-label to `'Pressure (Pa)'` and the title of the plot to `'Pressure (Pa) in Ghent (at -51.05, 3.71)'` (see notebook [visualization-01-matplotlib.ipynb](./visualization-01-matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements) for more information) +Define a Matplotlib `Figure` and `Axes` (respectively named `fig, ax`) and use it to create a plot that combines the yearly average of the pressure data in Gent with the monthly pressure data as function of time for that same pixel as line plots. Change the name of the y-label to `'Pressure (Pa)'` and the title of the plot to `'Pressure (Pa) in Ghent (at 51.05, 3.71)'` (see notebook [visualization-01-matplotlib.ipynb](./visualization-01-matplotlib.ipynb#An-small-cheat-sheet-reference-for-some-common-elements) for more information)
Hints @@ -555,14 +555,14 @@ ghent_pressure.plot.line(ax=ax) ghent_pressure.resample(time="YE").mean().plot.line(ax=ax) ax.set_ylabel('Pressure (Pa)') -ax.set_title('Pressure (Pa) in Ghent (-51.05, 3.71)') +ax.set_title('Pressure (Pa) in Ghent (51.05, 3.71)') ```
**EXERCISE**: -Select the precipitation data for the pixel closest to the center of Ghent (lat: -51.05, lon: 3.71) and assign the outcome to a new variable `ghent_precipitation`. +Select the precipitation data for the pixel closest to the center of Ghent (lat: 51.05, lon: 3.71) and assign the outcome to a new variable `ghent_precipitation`. For the Ghent pixel, calculate the maximal precipitation _for each month of the year_ (1 -> 12) and convert it to mm precipitation. From 2a1a14b2b43b3ba091819b45b072ed8d3128578e Mon Sep 17 00:00:00 2001 From: Joris Van den Bossche Date: Thu, 16 Oct 2025 15:39:20 +0200 Subject: [PATCH 3/3] dataset dims -> sizes --- notebooks/case-sea-surface-temperature.ipynb | 6 +++--- notebooks/case-sea-surface-temperature.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/notebooks/case-sea-surface-temperature.ipynb b/notebooks/case-sea-surface-temperature.ipynb index 43f2c77..1ff5383 100644 --- a/notebooks/case-sea-surface-temperature.ipynb +++ b/notebooks/case-sea-surface-temperature.ipynb @@ -133,7 +133,7 @@ "Hints\n", " \n", "- The number of elements or `size` of an array is an attribute of an xarray.DataArray and not of a xarray.Dataset\n", - "- Also the `shape` of an array is an attribute of an xarray.DataArray. A xarray.Dataset has the `dims` attribute to query dimension sizes\n", + "- Also the `shape` of an array is an attribute of an xarray.DataArray. A xarray.Dataset or DataArray has the `sizes` attribute to query dimension sizes\n", "\n", "
\n", " \n", @@ -190,8 +190,8 @@ }, "outputs": [], "source": [ - "# dims attribute of dataset object\n", - "ds.dims" + "# sizes attribute of dataset object\n", + "ds.sizes" ] }, { diff --git a/notebooks/case-sea-surface-temperature.md b/notebooks/case-sea-surface-temperature.md index 5b27fe4..f1b0543 100644 --- a/notebooks/case-sea-surface-temperature.md +++ b/notebooks/case-sea-surface-temperature.md @@ -90,7 +90,7 @@ The data contains a single data variable `sst` and has 3 dimensions: lon, lat an Hints - The number of elements or `size` of an array is an attribute of an xarray.DataArray and not of a xarray.Dataset -- Also the `shape` of an array is an attribute of an xarray.DataArray. A xarray.Dataset has the `dims` attribute to query dimension sizes +- Also the `shape` of an array is an attribute of an xarray.DataArray. A xarray.Dataset or DataArray has the `sizes` attribute to query dimension sizes
@@ -113,8 +113,8 @@ ds["sst"].shape ```{code-cell} ipython3 :tags: [nbtutor-solution] -# dims attribute of dataset object -ds.dims +# sizes attribute of dataset object +ds.sizes ``` ```{code-cell} ipython3