{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Simplification of roundabouts\n", "\n", "Analysis using street network can be sensitive to the actual geometry representation. For example, one roundabout can be typically represented as 4 or more nodes, while it is topologically only one. Hence measurements attempting to capture topology (e.g. centrality) or node density will be skewed.\n", "\n", "The following code exemplifies a simple process for road network simplification of roundabouts using `momepy.roundabout_simplification()`.\n", "\n", "For this example we will fetch some data from [OpenStreetMap](https://www.openstreetmap.org/#map=6/40.007/-2.488) (using `osmnx`). However, most other data sources should also work as long as their topology has been corrected and can be stored in a GeoDataFrame." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "import matplotlib.pyplot as plt\n", "import osmnx as ox\n", "\n", "import momepy as mm" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Load data\n", "Using `osmnx` download a neighborhood and reproject to its local CRS.\n", "\n", "Two things are required to achieve good results:\n", "1. Reproject the network to a projected CRS (in meters)\n", "1. Transform the graph to an undirected graph:\n", " - This helps to remove overlapping LineStrings once moving to GeoDataFrame.\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | \n", " | \n", " | osmid | \n", "oneway | \n", "name | \n", "highway | \n", "reversed | \n", "length | \n", "geometry | \n", "from | \n", "to | \n", "maxspeed | \n", "lanes | \n", "bridge | \n", "access | \n", "tunnel | \n", "junction | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
u | \n", "v | \n", "key | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
21990706 | \n", "21990729 | \n", "0 | \n", "390868364 | \n", "True | \n", "Calle de Mejía Lequerica | \n", "residential | \n", "False | \n", "60.664 | \n", "LINESTRING (440818.925 4475309.730, 440776.640... | \n", "21990706 | \n", "21990729 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
21990729 | \n", "25906107 | \n", "0 | \n", "163743121 | \n", "True | \n", "Calle de la Beneficencia | \n", "residential | \n", "False | \n", "65.736 | \n", "LINESTRING (440776.640 4475353.246, 440825.335... | \n", "21990729 | \n", "25906107 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
3144095503 | \n", "0 | \n", "390868364 | \n", "True | \n", "Calle de Mejía Lequerica | \n", "residential | \n", "False | \n", "1.550 | \n", "LINESTRING (440776.640 4475353.246, 440775.324... | \n", "21990729 | \n", "3144095503 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "