{ "cells": [ { "cell_type": "markdown", "id": "4dc8b5b9755684aa", "metadata": {}, "source": [ "# Coverage zones\n", "\n", "This notebook builds coverage zones of the example services on an intermodal `UrbanGraph`: every place is assigned\n", "to the service it reaches at the lowest network cost within a budget, so zones do not overlap. It shows\n", "\n", "- `get_graph_coverage` by distance (800 m) and by time (10 min);\n", "- `get_stepped_graph_coverage` in bands of 2 minutes, as Voronoi cells and as separate buffers;\n", "- the graph-free `get_radius_coverage`.\n", "\n", "The method is described on the [coverage page](../coverage.rst). The interactive maps show a light copy of every result\n", "(`for_map`: outlines simplified by 2 m), which keeps the notebook small.\n", "\n", "The last section, *Your own area*, shows what to replace to get the same pictures for another territory." ] }, { "cell_type": "code", "execution_count": 1, "id": "db56d2861ab407be", "metadata": { "ExecuteTime": { "end_time": "2026-07-10T10:05:52.330251Z", "start_time": "2026-07-10T10:05:52.325735Z" }, "execution": { "iopub.execute_input": "2026-11-06T16:15:52.509926Z", "iopub.status.busy": "2026-11-06T16:15:52.508921Z", "iopub.status.idle": "2026-11-06T16:15:52.513095Z", "shell.execute_reply": "2026-11-06T16:15:52.513095Z" } }, "outputs": [], "source": [ "# Install required packages (uncomment if needed)\n", "# !pip install iduedu pyarrow objectnat" ] }, { "cell_type": "code", "execution_count": 2, "id": "d568e9b461c6086a", "metadata": { "ExecuteTime": { "end_time": "2026-07-10T10:06:00.545968Z", "start_time": "2026-07-10T10:05:52.332766Z" }, "execution": { "iopub.execute_input": "2026-11-06T16:15:52.514099Z", "iopub.status.busy": "2026-11-06T16:15:52.514099Z", "iopub.status.idle": "2026-11-06T16:15:55.277734Z", "shell.execute_reply": "2026-11-06T16:15:55.277734Z" } }, "outputs": [], "source": [ "import geopandas as gpd\n", "import iduedu\n", "from iduedu import get_4326_boundary, get_intermodal_graph\n", "\n", "from objectnat import get_graph_coverage, get_radius_coverage, get_stepped_graph_coverage" ] }, { "cell_type": "code", "execution_count": 3, "id": "9e307cbd", "metadata": { "execution": { "iopub.execute_input": "2026-11-06T16:15:55.279796Z", "iopub.status.busy": "2026-11-06T16:15:55.279796Z", "iopub.status.idle": "2026-11-06T16:15:55.411469Z", "shell.execute_reply": "2026-11-06T16:15:55.411469Z" } }, "outputs": [], "source": [ "import folium\n", "\n", "\n", "def for_map(gdf, tolerance=2.0):\n", " \"\"\"A light copy for a web map: outlines simplified by `tolerance` metres, coordinates rounded to about 10 cm.\"\"\"\n", " local = gdf.to_crs(gdf.estimate_utm_crs())\n", " local[\"geometry\"] = local.simplify(tolerance)\n", " light = local.to_crs(4326)\n", " light[\"geometry\"] = light.geometry.set_precision(1e-6)\n", " return light[~light.is_empty]\n", "\n", "def grey_tiles():\n", " \"\"\"Light grey base map (Esri World Light Gray); its tiles end at zoom 16 and are stretched beyond it.\"\"\"\n", " return folium.TileLayer(\"Esri.WorldGrayCanvas\", max_zoom=19, max_native_zoom=16)" ] }, { "cell_type": "markdown", "id": "5084078ebb6beef2", "metadata": {}, "source": [ "## 1. Intermodal graph" ] }, { "cell_type": "code", "execution_count": 4, "id": "initial_id", "metadata": { "ExecuteTime": { "end_time": "2026-07-10T10:06:04.759829Z", "start_time": "2026-07-10T10:06:00.601794Z" }, "collapsed": true, "execution": { "iopub.execute_input": "2026-11-06T16:15:55.413525Z", "iopub.status.busy": "2026-11-06T16:15:55.413525Z", "iopub.status.idle": "2026-11-06T16:16:01.228856Z", "shell.execute_reply": "2026-11-06T16:16:01.228856Z" } }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "7f61903f300c47a29258b24e42288318", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Parsing ground PT routes: 0%| | 0/57 [00:00, ?it/s]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m2026-11-06 19:16:01.201\u001b[0m | \u001b[33m\u001b[1mWARNING \u001b[0m | \u001b[36miduedu.graph.transformers\u001b[0m:\u001b[36mkeep_largest_connected_component\u001b[0m:\u001b[36m64\u001b[0m - \u001b[33m\u001b[1mRemoving 338 nodes outside the largest strongly connected component. Retaining 21181 of 21519 nodes.\u001b[0m\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m2026-11-06 19:16:01.224\u001b[0m | \u001b[33m\u001b[1mWARNING \u001b[0m | \u001b[36miduedu.graph_builders.intermodal_builders\u001b[0m:\u001b[36mjoin_pt_walk_graph\u001b[0m:\u001b[36m248\u001b[0m - \u001b[33m\u001b[1mPublic transport nodes dropped with the smaller components: {'trolleybus': 2}\u001b[0m\n" ] } ], "source": [ "# Vasilyevsky Island district, Saint Petersburg (OSM relation 1114252).\n", "# IduEdu cuts the territory out of the Geofabrik extract (pip install \"iduedu[pbf]\");\n", "# without the `with` block the same calls query the Overpass API.\n", "with iduedu.use_pbf(osm_id=1114252, region=\"northwestern-fed-district\"):\n", " poly = get_4326_boundary(osm_id=1114252)\n", " G_intermodal = get_intermodal_graph(territory=poly, clip_by_territory=True)" ] }, { "cell_type": "markdown", "id": "18c5a199616284b0", "metadata": {}, "source": [ "## 2. Services\n", "\n", "36 services with a `name` and a `capacity` column (EPSG:32636)." ] }, { "cell_type": "code", "execution_count": 5, "id": "dc4ae5fbd2374af4", "metadata": { "ExecuteTime": { "end_time": "2026-07-10T10:06:04.812249Z", "start_time": "2026-07-10T10:06:04.774049Z" }, "execution": { "iopub.execute_input": "2026-11-06T16:16:01.231192Z", "iopub.status.busy": "2026-11-06T16:16:01.230184Z", "iopub.status.idle": "2026-11-06T16:16:01.276378Z", "shell.execute_reply": "2026-11-06T16:16:01.276378Z" } }, "outputs": [], "source": [ "services = gpd.read_parquet('examples_data/services.parquet')" ] }, { "cell_type": "markdown", "id": "9e3ebbd07107a149", "metadata": {}, "source": [ "## 3. Coverage by distance\n", "\n", "Zones within 800 m of network distance (`weight_type=\"length_meter\"`)." ] }, { "cell_type": "code", "execution_count": 6, "id": "239ae7c0ed8604a1", "metadata": { "ExecuteTime": { "end_time": "2026-07-10T10:06:39.506681Z", "start_time": "2026-07-10T10:06:38.516923Z" }, "execution": { "iopub.execute_input": "2026-11-06T16:16:01.278418Z", "iopub.status.busy": "2026-11-06T16:16:01.278418Z", "iopub.status.idle": "2026-11-06T16:16:06.694204Z", "shell.execute_reply": "2026-11-06T16:16:06.693700Z" } }, "outputs": [ { "data": { "text/html": [ "