Assignment 10¶

Due date: 22.06.2022

This week's assignment has to be returned in the form a jupyter notebook.

Don't forget the instructions!

01 - Maps with cartopy¶

For this assignment, you'll need to install cartopy first.

Your task is to make a map as close as possible to this one. It displays the location and elevation of all ZAMG weather stations in Austria. Some pointers to get you on track:

  • the location and elevation of all stations is read from the ZEHNMIN Stations-Metadaten.csv file that you can download here. pandas can read it without any problems.
  • the map is done with matplotlib and cartopy. I build my map based on elements from the following tutorials from the official documentation:
    • map tile aquisition for the map background
    • features for the country borders
    • grid lines and tick labels for the lat lon grid
    • matplotlib's ax.scatterplot as in the Iceland example for the station markers and ax.legend for the legend.

It is fine for me if you don't manage to do the exact same map mine needed . You can be creative as well! Any step towards completion is a good step. To help you further, here are all the imports I used for this task:

1
2
3
4
5
6
7
import pandas as pd

import matplotlib.pyplot as plt

import cartopy.crs as ccrs
import cartopy.feature as cfeature
import cartopy.io.img_tiles as cimgt
1
df = pd.read_csv('../project/ZEHNMIN Stations-Metadaten.csv')
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
stamen_terrain = cimgt.Stamen('terrain-background')

fig = plt.figure(figsize=(10, 5))

# Create a GeoAxes in the tile's projection.
ax = fig.add_subplot(projection=stamen_terrain.crs)

# Limit the extent of the map to a small longitude/latitude range.
ax.set_extent([8.5, 18, 46, 49.5], crs=ccrs.Geodetic())

# Add the Stamen data at zoom level 8.
ax.add_image(stamen_terrain, 10)
ax.add_feature(cfeature.BORDERS);

gl = ax.gridlines(draw_labels=True, linestyle=':')
gl.top_labels = False
gl.right_labels = False

# Add a marker for each station
s = df.loc[df['Höhe [m]'] < 1000]
ax.scatter(s['Länge [°E]'], s['Breite [°N]'], marker='o', color='C0', transform=ccrs.Geodetic(), 
           s=40, edgecolors='k', linewidths=1, zorder=99, label='h < 1000 m a.s.l.');

s = df.loc[(df['Höhe [m]'] >= 1000) & (df['Höhe [m]'] < 2000)]
ax.scatter(s['Länge [°E]'], s['Breite [°N]'], marker='v', color='C1', transform=ccrs.Geodetic(), 
           s=40, edgecolors='k', linewidths=1, zorder=99, label='1000 ≤ h < 2000 m a.s.l. ');

s = df.loc[df['Höhe [m]'] >= 2000]
ax.scatter(s['Länge [°E]'], s['Breite [°N]'], marker='s', color='C3', transform=ccrs.Geodetic(), 
           s=40, edgecolors='k', linewidths=1, zorder=99, label='h ≥ 2000 m a.s.l. ');

plt.title('ZAMG stations in Austria')
plt.legend()
plt.savefig('station_map.png', dpi=150, bbox_inches='tight');
No description has been provided for this image
1