From e32384fbe650b2464673661e2f1c36e5371d8c8b Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Thu, 25 Jun 2026 19:56:39 +0200 Subject: [PATCH 1/3] add a notice on how dataframe is printed as table --- workshop/jupyter/content/notebooks/04-vector-data.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/workshop/jupyter/content/notebooks/04-vector-data.ipynb b/workshop/jupyter/content/notebooks/04-vector-data.ipynb index 24bdb77..48c02c1 100644 --- a/workshop/jupyter/content/notebooks/04-vector-data.ipynb +++ b/workshop/jupyter/content/notebooks/04-vector-data.ipynb @@ -850,10 +850,12 @@ "metadata": {}, "outputs": [], "source": [ - "#load it as a GeoDataFrame, i.e. a Pandas DataFrame with with a geometry data column\n", + "#load a file as a GeoDataFrame, i.e. a Pandas DataFrame with with a geometry data column\n", "countries = gpd.read_file('../data/ne_110m_admin_0_countries/ne_110m_admin_0_countries.shp')\n", "\n", - "countries" + "# notice how a geodataframe is printed as a table by jupyter/ipython\n", + "countries\n", + "# also try `countries.plot()`, geopandas uses matplotlib to print a map of the dataframe" ] }, { From ced628b29dcfe28dcf17ff2c3792cc39f60bda34 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Thu, 25 Jun 2026 20:24:06 +0200 Subject: [PATCH 2/3] add a display to full vector example add aux.xml for performance output folder content should be ignored --- .gitignore | 1 + .../jupyter/content/data/output/.gitignore | 4 ++++ .../jupyter/content/data/world.rgb.tif.aux.xml | 18 ++++++++++++++++++ .../content/notebooks/04-vector-data.ipynb | 14 ++++++++------ .../content/notebooks/05-raster-data.ipynb | 14 +++++++------- 5 files changed, 38 insertions(+), 13 deletions(-) create mode 100644 workshop/jupyter/content/data/output/.gitignore create mode 100644 workshop/jupyter/content/data/world.rgb.tif.aux.xml diff --git a/.gitignore b/.gitignore index 31854eb..153ffe9 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ workshop/jupyter/content/data/woudc-stations.xml workshop/jupyter/content/data/srtm/srtm_high_pass.geotiff workshop/jupyter/content/notebooks/test/10-boreholes.gml workshop/jupyter/content/notebooks/test/10-populated-places-ba.json + diff --git a/workshop/jupyter/content/data/output/.gitignore b/workshop/jupyter/content/data/output/.gitignore new file mode 100644 index 0000000..2597d9e --- /dev/null +++ b/workshop/jupyter/content/data/output/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything +* +# But keep this file +!.gitignore \ No newline at end of file diff --git a/workshop/jupyter/content/data/world.rgb.tif.aux.xml b/workshop/jupyter/content/data/world.rgb.tif.aux.xml new file mode 100644 index 0000000..b4eadeb --- /dev/null +++ b/workshop/jupyter/content/data/world.rgb.tif.aux.xml @@ -0,0 +1,18 @@ + + + Red band + + 0 + 255 + 107.15079498291 + 66.706750840795 + 100 + + + + Green band + + + Blue band + + diff --git a/workshop/jupyter/content/notebooks/04-vector-data.ipynb b/workshop/jupyter/content/notebooks/04-vector-data.ipynb index 48c02c1..7a7d040 100644 --- a/workshop/jupyter/content/notebooks/04-vector-data.ipynb +++ b/workshop/jupyter/content/notebooks/04-vector-data.ipynb @@ -743,12 +743,14 @@ }, "outputs": [], "source": [ - "ds = ogr.Open('../data/04-ogr-out.gml')\n", - "layer = ds.GetLayer(0)\n", - "print(layer.GetFeatureCount())\n", - "print(layer.GetFeature(0).GetField('name'))\n", - "print(layer.GetFeature(0).GetField('code'))\n", - "ds.Destroy()" + "with ogr.Open('../data/04-ogr-out.gml') as ds:\n", + " layer = ds.GetLayer(0)\n", + " ft = layer.GetFeature(0)\n", + " display(ft.GetField('name'))\n", + " display(ft.GetField('code'))\n", + " # print the geometry using shapely\n", + " from shapely import from_wkb\n", + " display(from_wkb(bytes(ft.GetGeometryRef().ExportToWkb())))\n" ] }, { diff --git a/workshop/jupyter/content/notebooks/05-raster-data.ipynb b/workshop/jupyter/content/notebooks/05-raster-data.ipynb index cb2c494..1b5d243 100644 --- a/workshop/jupyter/content/notebooks/05-raster-data.ipynb +++ b/workshop/jupyter/content/notebooks/05-raster-data.ipynb @@ -62,11 +62,11 @@ "source": [ "from osgeo import gdal\n", "gdal.UseExceptions()\n", - "ds = gdal.Open('../data/world.rgb.tif')\n", - "band = ds.GetRasterBand(1)\n", - "print('band:', band.GetDescription())\n", - "min_val, max_val, mean_val, std_val = band.ComputeStatistics(False)\n", - "print('min:', min_val, 'max:', max_val, 'mean:', mean_val,'std:', std_val)" + "with gdal.Open('../data/world.rgb.tif') as ds:\n", + " band = ds.GetRasterBand(1)\n", + " print('band:', band.GetDescription())\n", + " min_val, max_val, mean_val, std_val = band.ComputeStatistics(False)\n", + " print('min:', min_val, 'max:', max_val, 'mean:', mean_val,'std:', std_val)" ] }, { @@ -109,8 +109,8 @@ "import matplotlib.pyplot as plt\n", "# Notice how the zarr file is referenced within the zip file\n", "raster_path = '/vsizip/../data/sample_geozarr.zarr.zip/sample_geozarr.zarr'\n", - "dataset = gdal.Open(raster_path)\n", - "r = plt.imshow(ds.GetRasterBand(1).ReadAsArray())\n" + "with gdal.Open(raster_path) as ds:\n", + " r = plt.imshow(ds.GetRasterBand(1).ReadAsArray())\n" ] }, { From 68dc061092e9b5a15b0ff22d72edaecc659d3847 Mon Sep 17 00:00:00 2001 From: Paul van Genuchten Date: Sun, 28 Jun 2026 12:49:06 +0200 Subject: [PATCH 3/3] centralize the .gitignore as suggested by @justb4 --- .gitignore | 2 +- workshop/jupyter/content/data/output/.gitignore | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 workshop/jupyter/content/data/output/.gitignore diff --git a/.gitignore b/.gitignore index 153ffe9..b9263da 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,4 @@ workshop/jupyter/content/data/woudc-stations.xml workshop/jupyter/content/data/srtm/srtm_high_pass.geotiff workshop/jupyter/content/notebooks/test/10-boreholes.gml workshop/jupyter/content/notebooks/test/10-populated-places-ba.json - +workshop/jupyter/content/data/output diff --git a/workshop/jupyter/content/data/output/.gitignore b/workshop/jupyter/content/data/output/.gitignore deleted file mode 100644 index 2597d9e..0000000 --- a/workshop/jupyter/content/data/output/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -# Ignore everything -* -# But keep this file -!.gitignore \ No newline at end of file