diff --git a/notebooks/00-osmnx-features-demo.ipynb b/notebooks/00-osmnx-features-demo.ipynb index 1bc446b..4f2a0b2 100644 --- a/notebooks/00-osmnx-features-demo.ipynb +++ b/notebooks/00-osmnx-features-demo.ipynb @@ -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", @@ -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)" ] diff --git a/notebooks/01-overview-osmnx.ipynb b/notebooks/01-overview-osmnx.ipynb index 1c7bbf5..518ae1b 100644 --- a/notebooks/01-overview-osmnx.ipynb +++ b/notebooks/01-overview-osmnx.ipynb @@ -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)." ] }, { @@ -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)" ] diff --git a/notebooks/03-graph-place-queries.ipynb b/notebooks/03-graph-place-queries.ipynb index 14c61e4..ad2b76a 100644 --- a/notebooks/03-graph-place-queries.ipynb +++ b/notebooks/03-graph-place-queries.ipynb @@ -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", diff --git a/notebooks/04-simplify-graph-consolidate-nodes.ipynb b/notebooks/04-simplify-graph-consolidate-nodes.ipynb index 12901ce..bf066d1 100644 --- a/notebooks/04-simplify-graph-consolidate-nodes.ipynb +++ b/notebooks/04-simplify-graph-consolidate-nodes.ipynb @@ -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)" ] @@ -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\")" ] diff --git a/notebooks/08-custom-filters-infrastructure.ipynb b/notebooks/08-custom-filters-infrastructure.ipynb index 41cf4f9..3884a29 100644 --- a/notebooks/08-custom-filters-infrastructure.ipynb +++ b/notebooks/08-custom-filters-infrastructure.ipynb @@ -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))" ] diff --git a/notebooks/14-osmnx-to-igraph.ipynb b/notebooks/14-osmnx-to-igraph.ipynb index 132765e..4f92ed7 100644 --- a/notebooks/14-osmnx-to-igraph.ipynb +++ b/notebooks/14-osmnx-to-igraph.ipynb @@ -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]" ] }, diff --git a/notebooks/16-download-osm-geospatial-features.ipynb b/notebooks/16-download-osm-geospatial-features.ipynb index 9883038..41bc4b5 100644 --- a/notebooks/16-download-osm-geospatial-features.ipynb +++ b/notebooks/16-download-osm-geospatial-features.ipynb @@ -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", @@ -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)" ] }, { diff --git a/notebooks/17-street-network-orientations.ipynb b/notebooks/17-street-network-orientations.ipynb index aa85b7d..f50e730 100644 --- a/notebooks/17-street-network-orientations.ipynb +++ b/notebooks/17-street-network-orientations.ipynb @@ -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",