Skip to content

Commit

Permalink
Merge pull request #90 from benchmark-urbanism/dev
Browse files Browse the repository at this point in the history
Updates graph cleaning
  • Loading branch information
songololo authored Nov 11, 2023
2 parents 698a48e + ece8fe3 commit e33ae27
Show file tree
Hide file tree
Showing 15 changed files with 426 additions and 559 deletions.
176 changes: 76 additions & 100 deletions demos/graph_cleaning.ipynb

Large diffs are not rendered by default.

116 changes: 51 additions & 65 deletions demos/graph_corrections.ipynb

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions demos/momepy_to_cityseer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -24,7 +24,7 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -46,7 +46,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 35/35 [00:00<00:00, 71193.33it/s]\n"
"100%|██████████| 35/35 [00:00<00:00, 10733.39it/s]\n"
]
}
],
Expand Down Expand Up @@ -77,16 +77,16 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:cityseer.tools.io:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 29/29 [00:00<00:00, 26384.99it/s]\n",
"100%|██████████| 29/29 [00:00<00:00, 2056.41it/s]\n"
"100%|██████████| 29/29 [00:00<00:00, 10736.59it/s]\n",
"100%|██████████| 29/29 [00:00<00:00, 1680.48it/s]\n"
]
}
],
Expand All @@ -103,7 +103,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 4,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -201,7 +201,7 @@
"x1603607.303-y6464181.853 1 POINT (1603607.303 6464181.853) "
]
},
"execution_count": 14,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -212,7 +212,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 5,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -351,7 +351,7 @@
"x1603585.64-y6464428.774-x1603650.45-y6464368.601 LINESTRING (1603585.640 6464428.774, 1603603.0... "
]
},
"execution_count": 15,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -362,7 +362,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -390,17 +390,17 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:cityseer.metrics.networks:Computing shortest path node centrality.\n",
"100%|██████████| 29/29 [00:01<00:00, 28.83it/s]\n",
"100%|██████████| 29/29 [00:01<00:00, 28.78it/s]\n",
"INFO:cityseer.metrics.layers:Computing land-use accessibility for: restaurant\n",
"100%|██████████| 29/29 [00:00<00:00, 9609.32it/s]\n"
"100%|██████████| 29/29 [00:01<00:00, 28.89it/s]\n"
]
},
{
Expand Down Expand Up @@ -488,7 +488,7 @@
" <td>102.0</td>\n",
" <td>0.000000</td>\n",
" <td>0.089877</td>\n",
" <td>5.084879</td>\n",
" <td>5.084880</td>\n",
" <td>1.0</td>\n",
" <td>0.134929</td>\n",
" <td>1.0</td>\n",
Expand Down Expand Up @@ -632,7 +632,7 @@
"\n",
" cc_metric_node_betweenness_beta_1000 \\\n",
"x1603585.64-y6464428.774 6.454369 \n",
"x1603413.206-y6464228.73 5.084879 \n",
"x1603413.206-y6464228.73 5.084880 \n",
"x1603268.502-y6464060.781 4.369751 \n",
"x1603363.558-y6464031.885 6.886633 \n",
"x1603607.303-y6464181.853 3.326667 \n",
Expand Down Expand Up @@ -682,7 +682,7 @@
"[5 rows x 33 columns]"
]
},
"execution_count": 17,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -703,7 +703,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand All @@ -712,14 +712,14 @@
"text": [
"INFO:cityseer.tools.graphs:Converting graph to dual.\n",
"INFO:cityseer.tools.graphs:Preparing dual nodes\n",
"100%|██████████| 35/35 [00:00<00:00, 16771.47it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 12677.08it/s]\n",
"INFO:cityseer.tools.graphs:Preparing dual edges (splitting and welding geoms)\n",
"100%|██████████| 35/35 [00:00<00:00, 262.43it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 320.17it/s]\n",
"INFO:cityseer.tools.io:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 35/35 [00:00<00:00, 29383.63it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 1722.69it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 12393.47it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 1384.22it/s]\n",
"INFO:cityseer.metrics.networks:Computing simplest path node centrality.\n",
"100%|██████████| 35/35 [00:01<00:00, 34.85it/s]\n"
"100%|██████████| 35/35 [00:01<00:00, 34.94it/s]\n"
]
},
{
Expand Down Expand Up @@ -896,7 +896,7 @@
"x1603363.558-y6464031.885_x1603413.206-y6464228... 10.0 "
]
},
"execution_count": 18,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
160 changes: 82 additions & 78 deletions demos/osm_to_cityseer.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/src/pages/rustalgos/rustalgos.md
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ datapoints are not located with high spatial precision.



<span class="name">node_ys</span><span class="annotation">: list[float]</span>
<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>



Expand All @@ -2736,7 +2736,7 @@ datapoints are not located with high spatial precision.



<span class="name">node_xys</span><span class="annotation">: list[tuple[float, float]]</span>
<span class="name">node_ys</span><span class="annotation">: list[float]</span>



Expand Down
41 changes: 13 additions & 28 deletions docs/src/pages/tools/graphs.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">despine</span>
<span class="pc">:</span>
<span class="pa"> float | None = None</span>
<span class="pa"> int = 15</span>
</div>
<div class="param">
<span class="pn">remove_disconnected</span>
Expand Down Expand Up @@ -163,11 +163,11 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param-set">
<div class="def">
<div class="name">despine</div>
<div class="type">bool</div>
<div class="type">int</div>
</div>
<div class="desc">

The maximum cutoff distance for removal of dead-ends. Use `None` or `0` where no despining should occur. Defaults to None.</div>
The maximum cutoff distance for removal of dead-ends. Use `0` where no despining should occur.</div>
</div>

<div class="param-set">
Expand Down Expand Up @@ -382,7 +382,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">buffer_dist</span>
<span class="pc">:</span>
<span class="pa"> float = 5</span>
<span class="pa"> float = 12</span>
</div>
<div class="param">
<span class="pn">neighbour_policy</span>
Expand All @@ -395,15 +395,10 @@ side-effects as a function of varied node intensities when computing network cen
<span class="pa"> bool = False</span>
</div>
<div class="param">
<span class="pn">centroid_by_straightness</span>
<span class="pn">centroid_by_itx</span>
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">centroid_by_min_len_factor</span>
<span class="pc">:</span>
<span class="pa"> float | None = None</span>
</div>
<div class="param">
<span class="pn">merge_edges_by_midline</span>
<span class="pc">:</span>
Expand All @@ -412,7 +407,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">contains_buffer_dist</span>
<span class="pc">:</span>
<span class="pa"> int = 20</span>
<span class="pa"> int = 40</span>
</div>
<span class="pt">)</span>
</div>
Expand Down Expand Up @@ -467,27 +462,17 @@ side-effects as a function of varied node intensities when computing network cen
</div>
<div class="desc">

Whether the algorithm will recursively explore neighbours of neighbours if those neighbours are within the buffer distance from the prior node. Defaults to True.</div>
Whether the algorithm will recursively explore neighbours of neighbours if those neighbours are within the buffer distance from the prior node. Defaults to False.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">centroid_by_straightness</div>
<div class="name">centroid_by_itx</div>
<div class="type">bool</div>
</div>
<div class="desc">

Whether to use an intersection straightness heuristic to select new centroids. True by default.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">centroid_by_min_len_factor</div>
<div class="type">float</div>
</div>
<div class="desc">

The minimum aggregate adjacent edge lengths an existing node should have to be considered when calculating the centroid for the new node cluster. Expressed as a factor of the node with the greatest aggregate adjacent edge lengths. Defaults to None.</div>
Whether to favour intersections when selecting the combined centroid of merged nodes. Intersections with two straight through-routes will be favoured if found, otherwise intersections with one straight through-route are used where available. True by default.</div>
</div>

<div class="param-set">
Expand All @@ -507,14 +492,14 @@ side-effects as a function of varied node intensities when computing network cen
</div>
<div class="desc">

The buffer distance to consider when checking if parallel edges are sufficiently similar to be merged.</div>
The buffer distance to consider when checking if parallel edges sharing the same start and end nodes are sufficiently similar to be merged. This is run after node consolidation has completed.</div>
</div>

### Returns
<div class="param-set">
<div class="def">
<div class="name"></div>
<div class="type">MultiGraph</div>
<div class="type">nx.MultiGraph</div>
</div>
<div class="desc">

Expand Down Expand Up @@ -546,7 +531,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">buffer_dist</span>
<span class="pc">:</span>
<span class="pa"> float = 10</span>
<span class="pa"> float = 12</span>
</div>
<div class="param">
<span class="pn">merge_edges_by_midline</span>
Expand All @@ -556,7 +541,7 @@ side-effects as a function of varied node intensities when computing network cen
<div class="param">
<span class="pn">contains_buffer_dist</span>
<span class="pc">:</span>
<span class="pa"> float = 20</span>
<span class="pa"> float = 40</span>
</div>
<span class="pt">)</span>
</div>
Expand Down
50 changes: 0 additions & 50 deletions docs/src/pages/tools/io.md
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ builds a graph automatically.
<span class="pc">:</span>
<span class="pa"> int | None = None</span>
</div>
<div class="param">
<span class="pn">buffer_dist</span>
<span class="pc">:</span>
<span class="pa"> int = 15</span>
</div>
<div class="param">
<span class="pn">custom_request</span>
<span class="pc">:</span>
Expand All @@ -378,21 +373,6 @@ builds a graph automatically.
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">remove_parallel</span>
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">iron_edges</span>
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">remove_disconnected</span>
<span class="pc">:</span>
<span class="pa"> bool = True</span>
</div>
<div class="param">
<span class="pn">timeout</span>
<span class="pc">:</span>
Expand Down Expand Up @@ -472,36 +452,6 @@ builds a graph automatically.
Whether to automatically simplify the OSM graph. Set to False for manual cleaning.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">remove_parallel</div>
<div class="type">bool</div>
</div>
<div class="desc">

Ignored if simplify is False. Whether to remove parallel roadway segments.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">iron_edges</div>
<div class="type">bool</div>
</div>
<div class="desc">

Ignored if simplify is False. Whether to straighten the ends of street segments. This can help to reduce the number of artefacts from segment kinks from merging `LineStrings`.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">remove_disconnected</div>
<div class="type">bool</div>
</div>
<div class="desc">

Ignored if simplify is False. Whether to remove disconnected components from the network.</div>
</div>

<div class="param-set">
<div class="def">
<div class="name">timeout</div>
Expand Down
Loading

0 comments on commit e33ae27

Please sign in to comment.