Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions notebooks/00-osmnx-features-demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"outputs": [],
"source": [
"# get a fully bidirection network (as a MultiDiGraph)\n",
"ox.settings.bidirectional_network_types += \"drive\"\n",
"ox.settings.bidirectional_network_types.append(\"drive\")\n",
"G = ox.graph.graph_from_place(\"Piedmont, California, USA\", network_type=\"drive\")\n",
"\n",
"# convert your MultiDiGraph to an undirected MultiGraph\n",
Expand Down Expand Up @@ -229,7 +229,7 @@
"metadata": {},
"outputs": [],
"source": [
"# impute missing edge speeds and calculate edge travel times with the speed module\n",
"# impute missing edge speeds and calculate edge travel times with the routing module\n",
"G = ox.routing.add_edge_speeds(G)\n",
"G = ox.routing.add_edge_travel_times(G)"
]
Expand Down
4 changes: 2 additions & 2 deletions notebooks/01-overview-osmnx.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@
"source": [
"## Part 3: simplifying street network topology\n",
"\n",
"Simplification is normally done by OSMnx automatically under the hood, but we can break it out to see how it works. OpenStreetMap nodes are weird. They include intersections, but they also include all the points along a single block where the street curves. The latter are not nodes in the graph theory sense, so we remove them algorithmically and consolidate the set of edges between \"true\" network nodes into a single edge. There are two simplification modes, strict and non-strict. The main difference is that unlike strict mode, non-strict mode allows simplification to an \"expansion graph\" (ie, if the graph were undirected, nodes with degree 2 as long as the incident edges have different OSM IDs). For a more in-depth demonstration of topological simplification with OSMnx, see [this notebook](04-simplify-graph-consolidate-nodes.ipynb)."
"Simplification is normally done by OSMnx automatically under the hood, but we can break it out to see how it works. OpenStreetMap nodes are weird. They include intersections, but they also include all the points along a single block where the street curves. The latter are not nodes in the graph theory sense, so we remove them algorithmically and consolidate the set of edges between \"true\" network nodes into a single edge. You can additionally retain nodes with specified attributes or where incident edges have different values for specified attributes by using the `node_attrs_include` and `edge_attrs_differ` parameters. For a more in-depth demonstration of topological simplification with OSMnx, see [this notebook](04-simplify-graph-consolidate-nodes.ipynb)."
]
},
{
Expand All @@ -354,7 +354,7 @@
"metadata": {},
"outputs": [],
"source": [
"# turn off strict mode and see what nodes we'd remove, in yellow\n",
"# identify endpoint nodes in red and nodes we'd remove in yellow\n",
"nc = [\"r\" if ox.simplification._is_endpoint(G, node, None, None) else \"y\" for node in G.nodes()]\n",
"fig, ax = ox.plot.plot_graph(G, node_color=nc)"
]
Expand Down
4 changes: 2 additions & 2 deletions notebooks/03-graph-place-queries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
" - `drive_service` - get drivable streets, including service roads\n",
" - `walk` - get all streets and paths that pedestrians can use (this network type ignores one-way directionality)\n",
" - `bike` - get all streets and paths that cyclists can use\n",
" - `all` - download all non-private OSM streets and paths\n",
" - `all_private` - download all OSM streets and paths, including private-access ones\n",
" - `all` - download all OSM streets and paths, including private-access ones\n",
" - `all_public` - download all non-private OSM streets and paths\n",
"\n",
"Or you can define your own fine-tuned network type using OSMnx's `custom_filter` parameter (to get just highways, or railways, canals, etc).\n",
"\n",
Expand Down
9 changes: 6 additions & 3 deletions notebooks/04-simplify-graph-consolidate-nodes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@
"metadata": {},
"outputs": [],
"source": [
"# turn off strict mode and see what nodes we'd remove\n",
"# identify endpoint nodes in red and nodes we'd remove in yellow\n",
"nc = [\n",
" \"r\" if ox.simplification._is_endpoint(G, node, [\"osmid\"], None) else \"y\" for node in G.nodes()\n",
" \"r\"\n",
" if ox.simplification._is_endpoint(G, node, node_attrs_include=None, edge_attrs_differ=[\"osmid\"])\n",
" else \"y\"\n",
" for node in G.nodes()\n",
"]\n",
"fig, ax = ox.plot.plot_graph(G, node_color=nc)"
]
Expand All @@ -206,7 +209,7 @@
"metadata": {},
"outputs": [],
"source": [
"# simplify network with strict mode turned off\n",
"# simplify network while retaining nodes whose incident edges have different `osmid` values\n",
"G3 = ox.simplification.simplify_graph(G.copy(), edge_attrs_differ=[\"osmid\"])\n",
"fig, ax = ox.plot.plot_graph(G3, node_color=\"r\")"
]
Expand Down
1 change: 0 additions & 1 deletion notebooks/08-custom-filters-infrastructure.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@
"\n",
"# union: get all ways with either a 'cycleway:right' or 'cycleway:left' tag\n",
"cf = [cf1, cf2]\n",
"ox.settings.useful_tags_way.extend([cf1, cf2])\n",
"G = ox.graph.graph_from_place(place, custom_filter=cf, retain_all=True)\n",
"print(len(G))"
]
Expand Down
2 changes: 1 addition & 1 deletion notebooks/14-osmnx-to-igraph.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"outputs": [],
"source": [
"%%time\n",
"closeness2 = nx.closeness_centrality(G_nx, distance=weight, wf_improved=True)\n",
"closeness2 = nx.closeness_centrality(G_nx.to_undirected(), distance=weight, wf_improved=True)\n",
"max_closeness2 = max(closeness2.items(), key=operator.itemgetter(1))[0]"
]
},
Expand Down
4 changes: 2 additions & 2 deletions notebooks/16-download-osm-geospatial-features.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Use the `geometries` module to download features, such as grocery stores, transit stops, points of interest, or building footprints, and turn them into a GeoDataFrame: [see docs](https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.geometries).\n",
"Use the `features` module to download features, such as grocery stores, transit stops, points of interest, or building footprints, and turn them into a GeoDataFrame: [see docs](https://osmnx.readthedocs.io/en/stable/osmnx.html#module-osmnx.features).\n",
"\n",
"To query, pass a `tags` dict where keys are OSM tags. The dict's values can be either:\n",
" 1. `True` to retrieve all OSM objects with this tag, regardless of its value\n",
Expand Down Expand Up @@ -149,7 +149,7 @@
"useful_tags = [\"access\", \"parking\", \"surface\", \"capacity\", \"fee\"]\n",
"for node, feature in zip(nn, features[useful_tags].to_dict(orient=\"records\"), strict=False):\n",
" feature = {k: v for k, v in feature.items() if pd.notna(v)}\n",
" G.nodes[node].update({\"parking\": feature})"
" G.nodes[node].setdefault(\"parking\", []).append(feature)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/17-street-network-orientations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
" print(ox.utils.ts(), place)\n",
"\n",
" # get undirected graphs with edge bearing attributes\n",
" G = ox.graph.graph_from_place(place, network_type=\"drive\")\n",
" G = ox.graph.graph_from_place(places[place], network_type=\"drive\")\n",
" Gu = ox.bearing.add_edge_bearings(ox.convert.to_undirected(G))\n",
" fig, ax = ox.plot.plot_orientation(Gu, ax=ax, title=place, area=True)\n",
"\n",
Expand Down