From 9abe29e71038fa0ab328f2a801226de765023fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yvonne=20Fr=C3=B6hlich?= <94163266+yvonnefroehlich@users.noreply.github.com> Date: Mon, 9 Dec 2024 07:54:17 -0500 Subject: [PATCH] Tutorial 02: Notes reading usage of own tabular data, dowload issue of river data (#35) --- book/tut02_spe_pd_gpd.ipynb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/book/tut02_spe_pd_gpd.ipynb b/book/tut02_spe_pd_gpd.ipynb index 012b0a3..2bc7475 100755 --- a/book/tut02_spe_pd_gpd.ipynb +++ b/book/tut02_spe_pd_gpd.ipynb @@ -60,6 +60,7 @@ "outputs": [], "source": [ "import geopandas as gpd\n", + "import pandas as pd\n", "import pygmt\n", "\n", "# Use a resolution of only 150 dpi for the images within the Jupyter notebook, to keep the file small\n", @@ -81,7 +82,8 @@ "source": [ "### 1.1 Tabular data - `pandas.DataFrame`\n", "\n", - "Use an example dataset with tabular data provided by `PyGMT` and load it into a `pandas.DataFrame`. This dataset contains earthquakes in the area of Japan." + "Use an example dataset with tabular data provided by `PyGMT` and load it into a `pandas.DataFrame`. This dataset contains earthquakes in the area of Japan.\n", + "You can read your own dataset into a `pandas.Dataframe` using [`pandas.read_csv`](https://pandas.pydata.org/docs/reference/api/pandas.read_csv.html) and use it in the same way to make the following plots; of course you have to adjust the column names accordantly." ] }, { @@ -92,7 +94,9 @@ "outputs": [], "source": [ "df_jp_eqs = pygmt.datasets.load_sample_data(name=\"japan_quakes\")\n", - "df_jp_eqs.head()" + "df_jp_eqs.head()\n", + "\n", + "# df_your_dataset = pd.read_csv(\"your_dataset.csv\")" ] }, { @@ -239,7 +243,12 @@ "source": [ "#### 2.1.1 Spatial Data - `geopandas.GeoDataFrame` with line geometry\n", "\n", - "First we download some data into in a [`geopandas.GeoDataFrame`](https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.html). This dataset contains European rivers with their lengths and names." + "First we download some data into in a [`geopandas.GeoDataFrame`](https://geopandas.org/en/stable/docs/reference/api/geopandas.GeoDataFrame.html). This dataset contains European rivers with their lengths and names.\n", + "\n", + "In case you face issues with downloading these data:\n", + "1. Copy the URL \"https://www.eea.europa.eu/data-and-maps/data/wise-large-rivers-and-large-lakes/zipped-shapefile-with-wise-large-rivers-vector-line/zipped-shapefile-with-wise-large-rivers-vector-line/at_download/file/wise_large_rivers.zip\" into your browser.\n", + "2. Download the zip file and place it into `~/agu24workshop/book`. Do not unpack the ZIP file.\n", + "3. Replace the URL with the filename of the ZIP file \"wise_large_rivers.zip\" in [`geopandas.read_file`](https://geopandas.org/en/stable/docs/reference/api/geopandas.read_file.html)." ] }, { @@ -254,6 +263,7 @@ " + \"zipped-shapefile-with-wise-large-rivers-vector-line/zipped-shapefile-with-wise-large-rivers-vector-line/\"\n", " + \"at_download/file/wise_large_rivers.zip\"\n", ")\n", + "# gpd_rivers_org = pd.read_file(\"wise_large_rivers.zip\")\n", "gpd_rivers_org.head()" ] }, @@ -542,7 +552,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.12.7" + "version": "3.12.6" } }, "nbformat": 4,