Skip to content

Commit 1e17055

Browse files
committed
Update osm.qmd, fix ci, speed-up
1 parent 08d75de commit 1e17055

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

osm.qmd

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,16 +364,25 @@ if (!"osmnx" %in% py_pkg_names) {
364364

365365
```{python}
366366
import osmnx as ox
367+
import pandas as pd
367368
import geopandas as gpd
368369
# Get cycle netework for Poznan
369370
poznan_polygon = ox.geocode_to_gdf("Poznan, Poland")
370371
poznan_polygon.plot();
371372
```
372373

373-
Download the cycling network for Poznan as follows:
374+
That is quite a big network, so let's get the area of the polygon and use that to get a smaller network from [GitHub](https://github.com/Robinlovelace/opengeohub2023/raw/main/pois_buffer_simple.geojson):
374375

375376
```{python}
376-
G_cycle = ox.graph_from_polygon(poznan_polygon.geometry[0], network_type="bike")
377+
# Get data from https://github.com/Robinlovelace/opengeohub2023/raw/main/pois_buffer_simple.geojson:
378+
poznan_small = gpd.read_file("https://github.com/Robinlovelace/opengeohub2023/raw/main/pois_buffer_simple.geojson")
379+
poznan_small.plot();
380+
```
381+
382+
Download the cycling network as follows:
383+
384+
```{python}
385+
G_cycle = ox.graph_from_polygon(poznan_small.geometry[0], network_type="bike")
377386
```
378387

379388
Plot the results:
@@ -385,6 +394,7 @@ ox.plot_graph(G_cycle)
385394
Get basic stats as follows:
386395

387396
```{python}
397+
area = ox.project_gdf(poznan_small).unary_union.area
388398
stats = ox.basic_stats(G_cycle, area=area)
389399
pd.Series(stats)
390400
```
@@ -394,14 +404,15 @@ Calculate the centrality across the network as follows:
394404
```{python}
395405
396406
```
407+
397408
We can convert the object into a 'GeoDataFrame' as follows:
398409

399410
```{python}
400411
cycle_gdf = ox.graph_to_gdfs(G_cycle, edges=True)
401-
402412
```
403413

404414
```{python}
415+
```
405416

406417
# Ideas for using OSM data {#sec-ideas}
407418

0 commit comments

Comments
 (0)