{ "cells": [ { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [], "source": [ "from pathlib import Path\n", "\n", "import pyrosm\n", "import geopandas as gpd\n", "import pandas as pd\n", "import shapely\n", "import pyproj\n", "\n", "import src.data.mapillary as mapi\n", "import src.data.osm as osmd\n", "#from src.data.mapillary import download_mapillary_image_by_key, download_mapillary_object_detection_by_key\n", "#from src.data.osm import add_mapillary_key_to_network\n", "from ipyleaflet import Map, Marker, Icon, Polyline, FullScreenControl\n", "from importlib import reload\n", "from tqdm.notebook import tqdm" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Settings" ] }, { "cell_type": "code", "execution_count": 106, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "input_filepath = \"../data/raw/berlin-latest.osm.pbf\"\n", "min_quality_score = 4\n", "output_dir = Path(\"../data/processed/out\")" ] }, { "cell_type": "markdown", "metadata": { "pycharm": { "name": "#%% md\n" } }, "source": [ "### Code (see make_dataset.py)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "osm = pyrosm.OSM(input_filepath)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "network = osm.get_network(\n", " network_type=\"cycling\",\n", " extra_attributes=[\"surface\", \"smoothness\"]\n", ")" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [], "source": [ "network = network.head(100)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "# Filter relevant columns\n", "network = network[[\"id\", \"geometry\", \"surface\", \"smoothness\"]]" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [], "source": [ "# Filter only records where both surface and smoothness is set\n", "network = network[(~network[\"surface\"].isna()) & (~network[\"smoothness\"].isna())]" ] }, { "cell_type": "code", "execution_count": 102, "metadata": { "pycharm": { "name": "#%%\n" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Request URL: https://a.mapillary.com/v3/images?client_id=TmxURHBKRFFFRTc1dWZscGpLWW5VUDo1ZjYyYmFjYjY5MTA3MDNk&bbox=13.526105139690427,52.4891476086417,13.5277082950903,52.49031200789549&per_page=500&sort_by=key&min_quality_score=4\n", "DONE\n", "Total images: 42\n" ] } ], "source": [ "# Get Mapillary keys for each street\n", "street_mapillary_df = osmd.add_mapillary_key_to_network(network.head(1), \n", " street_buffer=5,\n", " shorten_street_by=30,\n", " min_quality_score=min_quality_score)" ] }, { "cell_type": "code", "execution_count": 103, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | geometry | \n", "id | \n", "img_coords | \n", "mapillary_key | \n", "smoothness | \n", "surface | \n", "
---|---|---|---|---|---|---|
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5268612 52.4896728) | \n", "DQYk9CKOsaVKI5jgJyXsnQ | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5268964 52.4896935) | \n", "dfHVHCxaiLxOq5kxh88NeA | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5269718 52.4897393) | \n", "zyibnfVuppLVnlgGTImXxQ | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5270097 52.4897627) | \n", "pL2n6QmeQSa0mVlTyoLilw | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5270929 52.4898373) | \n", "rmpE7Tg1R2Vrb3W6ET2dQA | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5271284 52.4898888) | \n", "n6urwZz0q3NBs18aD3NULQ | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5271522 52.4899155) | \n", "NdcqcMPINtZwd_LfOozWdw | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5274044 52.4901188) | \n", "apY4zo5qfDD83lOJjdJEpQ | \n", "bad | \n", "sett | \n", "
2 | \n", "MULTILINESTRING ((13.52783 52.49043, 13.52639 ... | \n", "4045220.0 | \n", "POINT (13.5274312 52.490138) | \n", "zddDUI090ORSkTD8d2-SXA | \n", "bad | \n", "sett | \n", "