From 889387f34f3c6fda21605eb21777ac608e63a1ed Mon Sep 17 00:00:00 2001 From: anitagraser Date: Sun, 7 Feb 2021 23:24:46 +0100 Subject: [PATCH] Cleanup get_heatvulnerabilityindex_gdf --- notebooks/environment.ipynb | 6 ++++-- notebooks/utils/dataaccess.py | 17 +++++++++++++---- notebooks/utils/plotting.py | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/notebooks/environment.ipynb b/notebooks/environment.ipynb index 095da02..5618a22 100644 --- a/notebooks/environment.ipynb +++ b/notebooks/environment.ipynb @@ -32,7 +32,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## Urban Heat Vulnerability Index (UHVI) " + "## Urban Heat\n", + "\n", + "Dataset: [Urban Heat Vulnerability Index (UHVI)](https://www.data.gv.at/katalog/dataset/urban-heat-vulnerability-index-uhvi-wien)" ] }, { @@ -50,7 +52,7 @@ "metadata": {}, "outputs": [], "source": [ - "heatvulidx.hvplot(geo=True, tiles='OSM', c='AVG_UHVI_A', title='Urban Heat Vulnerability Index (AVG_UHVI_A)').opts(active_tools=['wheel_zoom'])" + "heatvulidx.hvplot(geo=True, tiles='OSM', c='AVG_UHVI_A', title='Average Urban Heat Vulnerability Index - All age groups').opts(active_tools=['wheel_zoom'])" ] }, { diff --git a/notebooks/utils/dataaccess.py b/notebooks/utils/dataaccess.py index 071ea16..70580bb 100644 --- a/notebooks/utils/dataaccess.py +++ b/notebooks/utils/dataaccess.py @@ -5,7 +5,7 @@ import pandas as pd def gdf_from_wfs(layer): """ - Get GeoPandas GeoDataFrame from data.wien.gv.at WFS service based on layer name + Get geopandas.GeoDataFrame from data.wien.gv.at WFS service based on layer name Parameters ---------- @@ -59,9 +59,10 @@ def get_weather_df(): df = pd.read_csv(file) return df -def get_heatvulnerabilityindex_gdf(): +def get_heatvulnerabilityindex_df(): """ - Get data from https://go.gv.at/l9lumesakt + Get pandas.DataFrame of heat vulnerability from + https://www.wien.gv.at/gogv/l9ogdaverageurbanheatvulnerabilityindex """ file = 'heatvulnerabilityindex.csv' url = 'https://www.wien.gv.at/gogv/l9ogdaverageurbanheatvulnerabilityindex' @@ -72,6 +73,14 @@ def get_heatvulnerabilityindex_gdf(): df['AVG_UHVI_O'] = df['AVG_UHVI_O'].str.replace(',', '.').astype(float) df['AVG_UHVI_Y'] = df['AVG_UHVI_Y'].str.replace(',', '.').astype(float) df.set_index('SUB_DISTRICT_CODE_VIE', inplace=True) + return df + +def get_heatvulnerabilityindex_gdf(): + """ + Get geopandas.GeoDataFrame of heat vulnerability from + https://www.wien.gv.at/gogv/l9ogdaverageurbanheatvulnerabilityindex + """ + df = get_heatvulnerabilityindex_df() districts = gdf_from_wfs('ZAEHLBEZIRKOGD') districts['SUB_DISTRICT_CODE_VIE'] = districts['ZBEZ'].astype(int) + 90000 districts.set_index('SUB_DISTRICT_CODE_VIE', inplace=True) @@ -80,7 +89,7 @@ def get_heatvulnerabilityindex_gdf(): def get_zaehlsprengel_gdf(year=2020): """ - Get Zählsprengel districts from Statistik Austria + Get geopandas.GeoDataFrame of Zählsprengel districts from Statistik Austria """ file = f'OGDEXT_ZSP_1_STATISTIK_AUSTRIA_{year}0101.zip' url = f'http://data.statistik.gv.at/data/OGDEXT_ZSP_1_STATISTIK_AUSTRIA_{year}0101.zip' diff --git a/notebooks/utils/plotting.py b/notebooks/utils/plotting.py index 0d47f7c..f8f5932 100644 --- a/notebooks/utils/plotting.py +++ b/notebooks/utils/plotting.py @@ -4,7 +4,7 @@ def hvplot_with_buffer(gdf, buffer_size, *args, **kwargs): Parameters ---------- - gdf : geopandas.Geodataframe + gdf : geopandas.GeoDataFrame point GeoDataFrame to plot buffer_size : numeric size of the buffer in meters (measured in EPSG:31287)