kopia lustrzana https://github.com/anitagraser/ogd-at-lab
Add environment notebook
rodzic
e2f19e3647
commit
74b0736e39
|
@ -130,3 +130,10 @@ dmypy.json
|
||||||
notebooks/CITYBIKEOGD.json
|
notebooks/CITYBIKEOGD.json
|
||||||
notebooks/ELADESTELLEOGD.json
|
notebooks/ELADESTELLEOGD.json
|
||||||
notebooks/6141610.txt
|
notebooks/6141610.txt
|
||||||
|
notebooks/heatvulnerabilityindex.csv
|
||||||
|
notebooks/LUFTGUETENETZOGD.json
|
||||||
|
notebooks/OGDEXT_ZSP_1_STATISTIK_AUSTRIA_20200101.zip
|
||||||
|
notebooks/WAHLSPRGR2020OGD.json
|
||||||
|
notebooks/ZAEHLBEZIRKOGD.json
|
||||||
|
notebooks/ZAEHLSPRGR0OGD.json
|
||||||
|
notebooks/lumesakt.csv
|
||||||
|
|
|
@ -0,0 +1,112 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"# Environmental Conditions in Vienna"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"[![Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/anitagraser/ogd-at-lab/main?urlpath=lab/tree/notebooks/environment.ipynb)\n",
|
||||||
|
"\n",
|
||||||
|
"\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import hvplot.pandas\n",
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"import geopandas as gpd\n",
|
||||||
|
"from utils.dataaccess import gdf_from_wfs, get_weather_df, get_heatvulnerabilityindex_gdf"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Urban Heat Vulnerability Index (UHVI) "
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"heatvulidx = get_heatvulnerabilityindex_gdf()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"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'])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"## Air Quality"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"stations = gdf_from_wfs('LUFTGUETENETZOGD')\n",
|
||||||
|
"stations.head()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"weather = get_weather_df()\n",
|
||||||
|
"weather"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.7.8"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 4
|
||||||
|
}
|
|
@ -19,6 +19,7 @@
|
||||||
"## Lab notebooks\n",
|
"## Lab notebooks\n",
|
||||||
"\n",
|
"\n",
|
||||||
"1. [Accessing geodata from data.wien.gv.at services](wien-ogd.ipynb)\n",
|
"1. [Accessing geodata from data.wien.gv.at services](wien-ogd.ipynb)\n",
|
||||||
|
"1. [Environmental conditions in Vienna](environment.ipynb)\n",
|
||||||
"1. [Geocoding addresses](geocoding.ipynb)\n",
|
"1. [Geocoding addresses](geocoding.ipynb)\n",
|
||||||
"1. [Getting elevation information](elevation.ipynb)"
|
"1. [Getting elevation information](elevation.ipynb)"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from urllib.request import urlretrieve
|
from urllib.request import urlretrieve
|
||||||
import geopandas as gpd
|
import geopandas as gpd
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
def gdf_from_wfs(layer):
|
def gdf_from_wfs(layer):
|
||||||
"""
|
"""
|
||||||
|
@ -47,4 +48,44 @@ def get_elevation(point):
|
||||||
if x_wert == raster_x:
|
if x_wert == raster_x:
|
||||||
elevationall = line.split(' ', 1 )[1]
|
elevationall = line.split(' ', 1 )[1]
|
||||||
return int(elevationall)
|
return int(elevationall)
|
||||||
|
|
||||||
|
def get_weather_df():
|
||||||
|
"""
|
||||||
|
Get data from https://go.gv.at/l9lumesakt
|
||||||
|
"""
|
||||||
|
file = 'lumesakt.csv'
|
||||||
|
url = 'https://go.gv.at/l9lumesakt'
|
||||||
|
urlretrieve(url, file)
|
||||||
|
df = pd.read_csv(file)
|
||||||
|
return df
|
||||||
|
|
||||||
|
def get_heatvulnerabilityindex_gdf():
|
||||||
|
"""
|
||||||
|
Get data from https://go.gv.at/l9lumesakt
|
||||||
|
"""
|
||||||
|
file = 'heatvulnerabilityindex.csv'
|
||||||
|
url = 'https://www.wien.gv.at/gogv/l9ogdaverageurbanheatvulnerabilityindex'
|
||||||
|
if not exists(file):
|
||||||
|
urlretrieve(url, file)
|
||||||
|
df = pd.read_csv(file, sep=';', encoding='latin1')
|
||||||
|
df['AVG_UHVI_A'] = df['AVG_UHVI_A'].str.replace(',', '.').astype(float)
|
||||||
|
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)
|
||||||
|
districts = gdf_from_wfs('ZAEHLBEZIRKOGD')
|
||||||
|
districts['SUB_DISTRICT_CODE_VIE'] = districts['ZBEZ'].astype(int) + 90000
|
||||||
|
districts.set_index('SUB_DISTRICT_CODE_VIE', inplace=True)
|
||||||
|
gdf = gpd.GeoDataFrame(pd.DataFrame(districts).join(df))
|
||||||
|
return gdf
|
||||||
|
|
||||||
|
def get_zaehlsprengel_gdf(year=2020):
|
||||||
|
"""
|
||||||
|
Get 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'
|
||||||
|
if not exists(file):
|
||||||
|
urlretrieve(url, file)
|
||||||
|
gdf = gpd.read_file(f'zip://{file}')
|
||||||
|
return gdf
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"\n",
|
"\n",
|
||||||
"For more information on open government data in Vienna visit [digitales.wien.gv.at](https://digitales.wien.gv.at/site/open-data/)\n",
|
"For more information on open government data in Vienna visit [digitales.wien.gv.at](https://digitales.wien.gv.at/site/open-data/)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"For a full list of available datasets go to [data.gv.at](https://www.data.gv.at/auftritte/?organisation=stadt-wien)\n",
|
"For a full list of available datasets go to [data.gv.at](https://www.data.gv.at/auftritte/?organisation=stadt-wien&searchterm=&formatFilter%5B%5D=WFS)\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n"
|
"\n"
|
||||||
]
|
]
|
||||||
|
@ -95,6 +95,16 @@
|
||||||
"hvplot_with_buffer(gdf, 100, title='Citybike Stations') + hvplot_with_buffer(gdf2, 100, title='EV Charging Stations')"
|
"hvplot_with_buffer(gdf, 100, title='Citybike Stations') + hvplot_with_buffer(gdf2, 100, title='EV Charging Stations')"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"election_districts = gdf_from_wfs('WAHLSPRGR2020OGD')\n",
|
||||||
|
"election_districts.hvplot(geo=True, tiles='OSM', alpha=0.5).opts(active_tools=['wheel_zoom'])"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|
Ładowanie…
Reference in New Issue