diff --git a/README.md b/README.md index dc68b0c..1a34718 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,5 @@ -# ogd-at-lab +# OGD.AT Lab + Notebooks for Austrian open gov data analysis + +[![Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ogd-at-lab/notebooks/main?urlpath=lab/tree/index.ipynb) diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..8b190ca --- /dev/null +++ b/environment.yml @@ -0,0 +1,21 @@ +name: ogd-at-lab +channels: + - conda-forge + - default +dependencies: + - python=3.7 + - numpy + - cython + - matplotlib + - seaborn + - pandas + - geopandas + - rasterio + - hvplot + - bokeh + - proj + - cartopy + - geoviews + - scikit-learn + - geopy + - panel diff --git a/notebooks/index.ipynb b/notebooks/index.ipynb new file mode 100644 index 0000000..93864c6 --- /dev/null +++ b/notebooks/index.ipynb @@ -0,0 +1,136 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "from os.path import exists\n", + "from urllib.request import urlretrieve\n", + "import geopandas as gpd\n", + "import hvplot.pandas" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "SIZE = 400" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def gdf_from_wfs(layer):\n", + " file = f'{layer}.json'\n", + " url = f\"https://data.wien.gv.at/daten/geo?service=WFS&request=GetFeature&version=1.1.0&typeName=ogdwien:{layer}&srsName=EPSG:4326&outputFormat=json\"\n", + " if not exists(file):\n", + " urlretrieve(url, file)\n", + " return gpd.read_file(file)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "gdf = gdf_from_wfs('ELADESTELLEOGD')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "gdf.hvplot(geo=True, tiles='OSM', width=SIZE, height=SIZE, hover_cols=['DESIGNATION']).opts(active_tools=['wheel_zoom'])" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "def hvplot_with_buffer(gdf, buffer_size, title=''):\n", + " buffered = gdf.to_crs('epsg:31287').buffer(100)\n", + " buffered = gdf.copy().set_geometry(buffered).to_crs('epsg:4326')\n", + " \n", + " plot = ( buffered.hvplot(geo=True, title=title, tiles='OSM', width=SIZE, height=SIZE, alpha=0.5, line_width=0) * \n", + " gdf.hvplot(geo=True, hover_cols=['DESIGNATION']) \n", + " ).opts(active_tools=['wheel_zoom'])\n", + " \n", + " return plot" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hvplot_with_buffer(gdf, 100)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "gdf2 = gdf_from_wfs('CITYBIKEOGD')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "hvplot_with_buffer(gdf, 100, title='EV Charging Stations') + hvplot_with_buffer(gdf2, 100, title='Citybike Stations')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "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 +}