Skip to content

Commit

Permalink
Merge pull request #84 from benchmark-urbanism/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
songololo authored Oct 15, 2023
2 parents e9bce11 + 013a251 commit 56b7d98
Show file tree
Hide file tree
Showing 100 changed files with 24,137 additions and 14,723 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/firebase-hosting-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Build docs
run: |
pdm install --dev
pdm run build_docs
pdm run generate_docs
- run: cd docs && npm install && npm run build && cd ..
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/firebase-hosting-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Build docs
run: |
pdm install --dev
pdm run build_docs
pdm run generate_docs
- run: cd docs && npm install && npm run build && cd ..
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# mac
.DS_Store

# code profiling
.prof

#setuptools_scm
cityseer/_version.py

Expand Down
6 changes: 4 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
"stylelint.packageManager": "pnpm",
"stylelint.reportInvalidScopeDisables": true,
"stylelint.reportNeedlessDisables": true,
"volar.codeLens.pugTools": true,
"volar.codeLens.scriptSetupTools": true,
"prettier.documentSelectors": ["**/*.astro"],
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[markdown]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
Expand Down
413 changes: 0 additions & 413 deletions demos/centrality/centrality_os_open.ipynb

This file was deleted.

421 changes: 0 additions & 421 deletions demos/centrality/centrality_osm.ipynb

This file was deleted.

2 changes: 1 addition & 1 deletion demos/continuity/continuity_os_open.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.6"
},
"orig_nbformat": 4,
"vscode": {
Expand Down
2 changes: 1 addition & 1 deletion demos/continuity/continuity_osm.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.6"
},
"vscode": {
"interpreter": {
Expand Down
2,300 changes: 1,134 additions & 1,166 deletions demos/getting_started.ipynb

Large diffs are not rendered by default.

157 changes: 76 additions & 81 deletions demos/graph_cleaning.ipynb

Large diffs are not rendered by default.

549 changes: 549 additions & 0 deletions demos/graph_corrections.ipynb

Large diffs are not rendered by default.

865 changes: 430 additions & 435 deletions demos/london_amenities.ipynb

Large diffs are not rendered by default.

413 changes: 413 additions & 0 deletions demos/london_centralities.ipynb

Large diffs are not rendered by default.

121 changes: 78 additions & 43 deletions demos/momepy_to_cityseer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
"source": [
"def nx_from_momepy(\n",
" gdf_network: gpd.GeoDataFrame, # type: ignore\n",
" crs: int | None = None,\n",
") -> nx.MultiGraph:\n",
" \"\"\"\n",
" Converts a `momepy` LineString GeoDataFrame to a `cityseer` compatible `networkX` `MultiGraph`.\n",
Expand All @@ -104,11 +103,7 @@
" if not gdf_network.crs.is_projected:\n",
" raise ValueError(\"The GeoDataframe CRS must be projected, i.e. not geographic.\")\n",
" g_multi = nx.MultiGraph()\n",
" if crs is None and \"crs\" not in g_multi.graph: # type: ignore\n",
" raise ValueError('\"crs\" not specified and cannot be found in graph metadata')\n",
" elif crs is not None and \"crs\" in g_multi.graph and crs != g_multi.graph[\"crs\"]:\n",
" raise ValueError(f'\"crs\" {crs} specified but mismatches graph metadata: {g_multi.graph[\"crs\"]}')\n",
" g_multi.graph[\"crs\"] = crs if crs is not None else gdf_network.graph[\"crs\"]\n",
" g_multi.graph[\"crs\"] = gdf_network.crs.to_epsg()\n",
"\n",
" def _node_key(node_coords: list[float]):\n",
" x = round(node_coords[0], 3)\n",
Expand All @@ -135,29 +130,29 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:cityseer.tools.graphs:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 29/29 [00:00<00:00, 19384.03it/s]\n",
"100%|██████████| 29/29 [00:00<00:00, 3078.19it/s]\n"
"INFO:cityseer.tools.io:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 29/29 [00:00<00:00, 15334.70it/s]\n",
"100%|██████████| 29/29 [00:00<00:00, 2989.97it/s]\n"
]
}
],
"source": [
"nx_momepy = nx_from_momepy(df_streets)\n",
"# optionally use cityseer to clean network\n",
"# if using primal network\n",
"nodes_gdf, edges_gdf, network_structure = graphs.network_structure_from_nx(nx_momepy, crs=nx_momepy.graph[\"crs\"])"
"nodes_gdf, edges_gdf, network_structure = io.network_structure_from_nx(nx_momepy, crs=nx_momepy.graph[\"crs\"])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -249,7 +244,7 @@
"x1603607.303-y6464181.853-zNaN POINT (1603607.303 6464181.853) "
]
},
"execution_count": 6,
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -260,7 +255,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -404,7 +399,7 @@
"x1603585.64-y6464428.774-zNaN-x1603650.45-y6464... LINESTRING (1603585.640 6464428.774, 1603603.0... "
]
},
"execution_count": 7,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -415,7 +410,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -434,7 +429,7 @@
"Name: amenity, dtype: object"
]
},
"execution_count": 8,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -445,16 +440,16 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"100%|██████████| 29/29 [00:01<00:00, 28.85it/s]\n",
"100%|██████████| 29/29 [00:01<00:00, 28.89it/s]\n",
"INFO:cityseer.metrics.layers:Computing land-use accessibility for: restaurant\n",
"100%|██████████| 29/29 [00:01<00:00, 28.84it/s]\n"
"100%|██████████| 29/29 [00:01<00:00, 28.88it/s]\n"
]
},
{
Expand Down Expand Up @@ -518,7 +513,7 @@
" <td>77.0</td>\n",
" <td>0.105017</td>\n",
" <td>1.056299</td>\n",
" <td>6.454368</td>\n",
" <td>6.454370</td>\n",
" <td>0.0</td>\n",
" <td>0.000000</td>\n",
" <td>0.0</td>\n",
Expand Down Expand Up @@ -590,7 +585,7 @@
" <td>87.0</td>\n",
" <td>0.000000</td>\n",
" <td>0.676959</td>\n",
" <td>6.886633</td>\n",
" <td>6.886635</td>\n",
" <td>0.0</td>\n",
" <td>0.000000</td>\n",
" <td>1.0</td>\n",
Expand Down Expand Up @@ -699,10 +694,10 @@
"x1603607.303-y6464181.853-zNaN 0.263284 \n",
"\n",
" cc_metric_node_betweenness_beta_1000 \\\n",
"x1603585.64-y6464428.774-zNaN 6.454368 \n",
"x1603585.64-y6464428.774-zNaN 6.454370 \n",
"x1603413.206-y6464228.73-zNaN 5.084879 \n",
"x1603268.502-y6464060.781-zNaN 4.369751 \n",
"x1603363.558-y6464031.885-zNaN 6.886633 \n",
"x1603363.558-y6464031.885-zNaN 6.886635 \n",
"x1603607.303-y6464181.853-zNaN 3.326667 \n",
"\n",
" cc_metric_restaurant_100_non_weighted \\\n",
Expand Down Expand Up @@ -750,7 +745,7 @@
"[5 rows x 32 columns]"
]
},
"execution_count": 10,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -771,19 +766,22 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:cityseer.tools.graphs:Converting graph to dual.\n",
"100%|██████████| 35/35 [00:00<00:00, 448.29it/s]\n",
"INFO:cityseer.tools.graphs:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 35/35 [00:00<00:00, 48835.87it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 1713.82it/s]\n",
"100%|██████████| 35/35 [00:01<00:00, 34.81it/s]\n"
"INFO:cityseer.tools.graphs:Preparing dual nodes\n",
"100%|██████████| 35/35 [00:00<00:00, 18306.60it/s]\n",
"INFO:cityseer.tools.graphs:Preparing dual edges (splitting and welding geoms)\n",
"100%|██████████| 35/35 [00:00<00:00, 436.73it/s]\n",
"INFO:cityseer.tools.io:Preparing node and edge arrays from networkX graph.\n",
"100%|██████████| 35/35 [00:00<00:00, 44243.71it/s]\n",
"100%|██████████| 35/35 [00:00<00:00, 1642.75it/s]\n",
"100%|██████████| 35/35 [00:01<00:00, 34.82it/s]\n"
]
},
{
Expand Down Expand Up @@ -812,59 +810,77 @@
" <th>y</th>\n",
" <th>live</th>\n",
" <th>geom</th>\n",
" <th>primal_edge_node_a</th>\n",
" <th>primal_edge_node_b</th>\n",
" <th>primal_edge_idx</th>\n",
" <th>cc_metric_node_harmonic_simplest_500</th>\n",
" <th>cc_metric_node_betweenness_simplest_500</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>x1603413.206-y6464228.73-zNaN_x1603585.64-y6464428.774-zNaN</th>\n",
" <th>x1603413.206-y6464228.73-zNaN_x1603585.64-y6464428.774-zNaN_k0</th>\n",
" <td>0</td>\n",
" <td>1.603499e+06</td>\n",
" <td>6.464329e+06</td>\n",
" <td>True</td>\n",
" <td>POINT (1603499.423 6464328.752)</td>\n",
" <td>x1603585.64-y6464428.774-zNaN</td>\n",
" <td>x1603413.206-y6464228.73-zNaN</td>\n",
" <td>0</td>\n",
" <td>11.059296</td>\n",
" <td>9.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x1603561.74-y6464494.467-zNaN_x1603585.64-y6464428.774-zNaN</th>\n",
" <th>x1603561.74-y6464494.467-zNaN_x1603585.64-y6464428.774-zNaN_k0</th>\n",
" <td>1</td>\n",
" <td>1.603573e+06</td>\n",
" <td>6.464461e+06</td>\n",
" <td>True</td>\n",
" <td>POINT (1603572.785 6464461.339)</td>\n",
" <td>x1603585.64-y6464428.774-zNaN</td>\n",
" <td>x1603561.74-y6464494.467-zNaN</td>\n",
" <td>0</td>\n",
" <td>7.831646</td>\n",
" <td>10.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x1603585.64-y6464428.774-zNaN_x1603650.45-y6464368.601-zNaN</th>\n",
" <th>x1603585.64-y6464428.774-zNaN_x1603650.45-y6464368.601-zNaN_k0</th>\n",
" <td>2</td>\n",
" <td>1.603619e+06</td>\n",
" <td>6.464400e+06</td>\n",
" <td>True</td>\n",
" <td>POINT (1603619.295 6464399.737)</td>\n",
" <td>x1603585.64-y6464428.774-zNaN</td>\n",
" <td>x1603650.45-y6464368.601-zNaN</td>\n",
" <td>0</td>\n",
" <td>7.865049</td>\n",
" <td>14.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x1603413.206-y6464228.73-zNaN_x1603607.303-y6464181.853-zNaN</th>\n",
" <th>x1603413.206-y6464228.73-zNaN_x1603607.303-y6464181.853-zNaN_k0</th>\n",
" <td>3</td>\n",
" <td>1.603510e+06</td>\n",
" <td>6.464204e+06</td>\n",
" <td>True</td>\n",
" <td>POINT (1603510.094 6464204.494)</td>\n",
" <td>x1603413.206-y6464228.73-zNaN</td>\n",
" <td>x1603607.303-y6464181.853-zNaN</td>\n",
" <td>0</td>\n",
" <td>13.298367</td>\n",
" <td>8.0</td>\n",
" </tr>\n",
" <tr>\n",
" <th>x1603363.558-y6464031.885-zNaN_x1603413.206-y6464228.73-zNaN</th>\n",
" <th>x1603363.558-y6464031.885-zNaN_x1603413.206-y6464228.73-zNaN_k0</th>\n",
" <td>4</td>\n",
" <td>1.603388e+06</td>\n",
" <td>6.464130e+06</td>\n",
" <td>True</td>\n",
" <td>POINT (1603388.005 6464130.401)</td>\n",
" <td>14.422626</td>\n",
" <td>x1603413.206-y6464228.73-zNaN</td>\n",
" <td>x1603363.558-y6464031.885-zNaN</td>\n",
" <td>0</td>\n",
" <td>14.921643</td>\n",
" <td>10.0</td>\n",
" </tr>\n",
" </tbody>\n",
Expand Down Expand Up @@ -893,12 +909,33 @@
"x1603413.206-y6464228.73-zNaN_x1603607.303-y646... POINT (1603510.094 6464204.494) \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... POINT (1603388.005 6464130.401) \n",
"\n",
" primal_edge_node_a \\\n",
"x1603413.206-y6464228.73-zNaN_x1603585.64-y6464... x1603585.64-y6464428.774-zNaN \n",
"x1603561.74-y6464494.467-zNaN_x1603585.64-y6464... x1603585.64-y6464428.774-zNaN \n",
"x1603585.64-y6464428.774-zNaN_x1603650.45-y6464... x1603585.64-y6464428.774-zNaN \n",
"x1603413.206-y6464228.73-zNaN_x1603607.303-y646... x1603413.206-y6464228.73-zNaN \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... x1603413.206-y6464228.73-zNaN \n",
"\n",
" primal_edge_node_b \\\n",
"x1603413.206-y6464228.73-zNaN_x1603585.64-y6464... x1603413.206-y6464228.73-zNaN \n",
"x1603561.74-y6464494.467-zNaN_x1603585.64-y6464... x1603561.74-y6464494.467-zNaN \n",
"x1603585.64-y6464428.774-zNaN_x1603650.45-y6464... x1603650.45-y6464368.601-zNaN \n",
"x1603413.206-y6464228.73-zNaN_x1603607.303-y646... x1603607.303-y6464181.853-zNaN \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... x1603363.558-y6464031.885-zNaN \n",
"\n",
" primal_edge_idx \\\n",
"x1603413.206-y6464228.73-zNaN_x1603585.64-y6464... 0 \n",
"x1603561.74-y6464494.467-zNaN_x1603585.64-y6464... 0 \n",
"x1603585.64-y6464428.774-zNaN_x1603650.45-y6464... 0 \n",
"x1603413.206-y6464228.73-zNaN_x1603607.303-y646... 0 \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... 0 \n",
"\n",
" cc_metric_node_harmonic_simplest_500 \\\n",
"x1603413.206-y6464228.73-zNaN_x1603585.64-y6464... 11.059296 \n",
"x1603561.74-y6464494.467-zNaN_x1603585.64-y6464... 7.831646 \n",
"x1603585.64-y6464428.774-zNaN_x1603650.45-y6464... 7.865049 \n",
"x1603413.206-y6464228.73-zNaN_x1603607.303-y646... 13.298367 \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... 14.422626 \n",
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... 14.921643 \n",
"\n",
" cc_metric_node_betweenness_simplest_500 \n",
"x1603413.206-y6464228.73-zNaN_x1603585.64-y6464... 9.0 \n",
Expand All @@ -908,17 +945,15 @@
"x1603363.558-y6464031.885-zNaN_x1603413.206-y64... 10.0 "
]
},
"execution_count": 11,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# if using dual network\n",
"nx_dual = graphs.nx_to_dual(nx_momepy)\n",
"nodes_gdf_dual, _edges_gdf_dual, network_structure_dual = graphs.network_structure_from_nx(\n",
" nx_dual, nx_momepy.graph[\"crs\"]\n",
")\n",
"nodes_gdf_dual, _edges_gdf_dual, network_structure_dual = io.network_structure_from_nx(nx_dual, nx_momepy.graph[\"crs\"])\n",
"nodes_gdf_dual = networks.node_centrality_simplest(network_structure_dual, nodes_gdf_dual, [500])\n",
"nodes_gdf_dual.head()"
]
Expand All @@ -940,7 +975,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
"version": "3.11.6"
},
"orig_nbformat": 4
},
Expand Down
Loading

0 comments on commit 56b7d98

Please sign in to comment.