Skip to content

Commit

Permalink
Update osm.qmd, fix ci, speed-up
Browse files Browse the repository at this point in the history
  • Loading branch information
Robinlovelace committed Aug 31, 2023
1 parent 08d75de commit 1e17055
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions osm.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -364,16 +364,25 @@ if (!"osmnx" %in% py_pkg_names) {

```{python}
import osmnx as ox
import pandas as pd
import geopandas as gpd
# Get cycle netework for Poznan
poznan_polygon = ox.geocode_to_gdf("Poznan, Poland")
poznan_polygon.plot();
```

Download the cycling network for Poznan as follows:
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):

```{python}
G_cycle = ox.graph_from_polygon(poznan_polygon.geometry[0], network_type="bike")
# Get data from https://github.com/Robinlovelace/opengeohub2023/raw/main/pois_buffer_simple.geojson:
poznan_small = gpd.read_file("https://github.com/Robinlovelace/opengeohub2023/raw/main/pois_buffer_simple.geojson")
poznan_small.plot();
```

Download the cycling network as follows:

```{python}
G_cycle = ox.graph_from_polygon(poznan_small.geometry[0], network_type="bike")
```

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

```{python}
area = ox.project_gdf(poznan_small).unary_union.area
stats = ox.basic_stats(G_cycle, area=area)
pd.Series(stats)
```
Expand All @@ -394,14 +404,15 @@ Calculate the centrality across the network as follows:
```{python}
```

We can convert the object into a 'GeoDataFrame' as follows:

```{python}
cycle_gdf = ox.graph_to_gdfs(G_cycle, edges=True)
```

```{python}
```

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

Expand Down

0 comments on commit 1e17055

Please sign in to comment.