Add mobility notebook

course
anitagraser 2021-02-10 12:45:33 +01:00
rodzic be7d5806ea
commit f7cf1a5ed9
3 zmienionych plików z 114 dodań i 1 usunięć

1
.gitignore vendored
Wyświetl plik

@ -137,3 +137,4 @@ notebooks/WAHLSPRGR2020OGD.json
notebooks/ZAEHLBEZIRKOGD.json
notebooks/ZAEHLSPRGR0OGD.json
notebooks/lumesakt.csv
*.zip

Wyświetl plik

@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Urban Mobility\n",
"\n",
"[![Binder](http://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/anitagraser/ogd-at-lab/main?urlpath=lab/tree/notebooks/mobility.ipynb)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import hvplot.pandas\n",
"from utils.dataaccess import get_uber_movement_gdf"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Uber Movement\n",
"\n",
"Source: https://movement.uber.com/explore/vienna/travel-times\n",
"\n",
"© 2021 Copyright Uber Technologies. Data made available under the [Creative Commons, Attribution Non-Commercial](https://creativecommons.org/licenses/by-nc/3.0/us/) license"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"gdf = get_uber_movement_gdf()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"ID = 3\n",
"COL = 'mean_travel_time'\n",
"MONTH = 1\n",
"( \n",
" gdf[(gdf.sourceid==ID) & (gdf.month==MONTH)].dropna(subset=[COL]).hvplot(\n",
" geo=True, tiles='OSM', c=COL, title=f'{COL.title()} - Month: 2020-{MONTH}') * \n",
" gdf[gdf.index==ID].hvplot(geo=True).opts(active_tools=['wheel_zoom'])\n",
")"
]
},
{
"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
}

Wyświetl plik

@ -117,4 +117,29 @@ def get_zaehlsprengel_gdf(year=2020):
urlretrieve(url, file)
gdf = gpd.read_file(f'zip://{file}')
return gdf
def get_uber_movement_gdf():
"""
Get geopandas.GeoDataFrame of Uber Movement data
Source: https://movement.uber.com/explore/vienna/travel-times
© 2021 Copyright Uber Technologies, Inc. Data Attributions
Data is made available under [CC BY-NC 3.0 US](https://creativecommons.org/licenses/by-nc/3.0/us/)
"""
file = 'uber_vienna_statistical_areas.zip'
url = 'https://github.com/anitagraser/ogd-at-lab-data/raw/main/uber/vienna_statistical_areas.zip'
if not exists(file):
urlretrieve(url, file)
gdf = gpd.read_file(f'zip://{file}')
gdf['MOVEMENT_ID'] = gdf['MOVEMENT_ID'].astype(int)
gdf.set_index('MOVEMENT_ID', inplace=True)
file = 'uber_vienna-statistical_areas-2020-1-All-MonthlyAggregate.zip'
url = 'https://github.com/anitagraser/ogd-at-lab-data/raw/main/uber/vienna-statistical_areas-2020-1-All-MonthlyAggregate.zip'
if not exists(file):
urlretrieve(url, file)
df = pd.read_csv(file)
df.set_index('dstid', inplace=True)
return gdf.join(df)