Geosphere Austria tutorialΒΆ

This tutorial walks through the use of a point data class for accessing station data in Austria A video tutorial of this notebook can be found here

[1]:
# import metloom class https://data.hub.geosphere.at/dataset/
from metloom.pointdata import GeoSphereHistPointData
[2]:
# import packages
import geopandas as gpd
import pandas as pd
import matplotlib.pyplot as plt
[3]:
# Install mapclassify and folium for gdf.explore()
!pip install mapclassify
!pip install folium
Requirement already satisfied: mapclassify in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (2.8.1)
Requirement already satisfied: networkx>=2.7 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from mapclassify) (3.4.2)
Requirement already satisfied: numpy>=1.23 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from mapclassify) (2.2.6)
Requirement already satisfied: pandas!=1.5.0,>=1.4 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from mapclassify) (2.3.3)
Requirement already satisfied: scikit-learn>=1.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from mapclassify) (1.7.2)
Requirement already satisfied: scipy>=1.8 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from mapclassify) (1.15.3)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas!=1.5.0,>=1.4->mapclassify) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas!=1.5.0,>=1.4->mapclassify) (2026.1.post1)
Requirement already satisfied: tzdata>=2022.7 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from pandas!=1.5.0,>=1.4->mapclassify) (2026.1)
Requirement already satisfied: six>=1.5 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from python-dateutil>=2.8.2->pandas!=1.5.0,>=1.4->mapclassify) (1.17.0)
Requirement already satisfied: joblib>=1.2.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from scikit-learn>=1.0->mapclassify) (1.5.3)
Requirement already satisfied: threadpoolctl>=3.1.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from scikit-learn>=1.0->mapclassify) (3.6.0)
Requirement already satisfied: folium in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (0.20.0)
Requirement already satisfied: branca>=0.6.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from folium) (0.8.2)
Requirement already satisfied: jinja2>=2.9 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from folium) (3.1.6)
Requirement already satisfied: numpy in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from folium) (2.2.6)
Requirement already satisfied: requests in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from folium) (2.33.1)
Requirement already satisfied: xyzservices in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from folium) (2026.3.0)
Requirement already satisfied: MarkupSafe>=2.0 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from jinja2>=2.9->folium) (2.0.1)
Requirement already satisfied: charset_normalizer<4,>=2 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests->folium) (3.4.7)
Requirement already satisfied: idna<4,>=2.5 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests->folium) (3.11)
Requirement already satisfied: urllib3<3,>=1.26 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests->folium) (2.6.3)
Requirement already satisfied: certifi>=2023.5.7 in /home/docs/checkouts/readthedocs.org/user_builds/metloom/envs/stable/lib/python3.10/site-packages (from requests->folium) (2026.2.25)
[4]:
# read and explore shape
gdf = gpd.read_file("./data/geosphere_test.kml")
gdf.explore()
[4]:
Make this Notebook Trusted to load map: File -> Trust Notebook
[5]:
# Define variable of interest https://github.com/M3Works/metloom/blob/main/metloom/variables.py
variable = GeoSphereHistPointData.ALLOWED_VARIABLES.TEMP
# Get the points within our region of interest
points = GeoSphereHistPointData.points_from_geometry(gdf, [variable])
print(len(points))
56
[6]:
# Explore the points we located
points_df = points.to_dataframe()
points_df = points_df.set_crs("EPSG:4326")

points_df.explore()
[6]:
Make this Notebook Trusted to load map: File -> Trust Notebook
[7]:
# define start and end date of interest
start = pd.to_datetime("2023-01-01")
end = pd.to_datetime("2023-01-11")
[8]:
# dataframe for storing combined data
final_df = pd.DataFrame()

# loop through first 15 points and store the data
for p in points.points[:15]:
    result = p.get_daily_data(start, end, [variable])
    if result is None:
        print(f"{p.name} did not return data")
    else:
        # reset the index to just be datetime
        result = result.reset_index().set_index("datetime")
        # store off the data in the final dataframe
        final_df[p.name + p.id] = result[variable.name]
final_df
RADSTADT did not return data
WAGRAIN did not return data
ST.NIKOLAI did not return data
BAD GASTEIN did not return data
ST.MICHAEL/LUNGAU did not return data
TAMSWEG did not return data
TAMSWEG did not return data
OBERWOELZ did not return data
KRAKAUEBENE/TERRASSE did not return data
STOLZALPE did not return data
OBERVELLACH did not return data
[8]:
OBERTAUERN15610 KATSCHBERG15715 OBERVELLACH18122 FLATTNITZ18402
datetime
2023-01-01 00:00:00+00:00 2.8 1.5 -1.6 -1.6
2023-01-02 00:00:00+00:00 1.6 2.0 -1.8 -1.7
2023-01-03 00:00:00+00:00 1.0 2.0 -0.7 -0.7
2023-01-04 00:00:00+00:00 -1.8 -0.5 -2.4 -1.6
2023-01-05 00:00:00+00:00 4.4 5.8 -1.8 3.7
2023-01-06 00:00:00+00:00 -0.7 0.7 3.1 -1.0
2023-01-07 00:00:00+00:00 -0.9 -0.6 -3.1 -2.9
2023-01-08 00:00:00+00:00 -5.2 -2.9 -4.4 -3.0
2023-01-09 00:00:00+00:00 -1.0 0.0 3.0 0.4
2023-01-10 00:00:00+00:00 -5.0 -2.3 6.8 -1.7
2023-01-11 00:00:00+00:00 -3.2 -1.8 -1.7 -4.1
[9]:
# Plot the timeseries
final_df.plot(ylabel=variable.name)
[9]:
<Axes: xlabel='datetime', ylabel='Air temperature 2m on observation date'>
../_images/gallery_geosphere_tutorial_9_1.png
[ ]: