Closed MaherSaid closed 2 years ago
A temporary get-around for the above issue that I switched to - after figuring out which combination of counties doesn't result in an error - is using nx.compose()
to join the multiple networks into one large network. Here's an example using the bay area.
My concern with this is the potential for nodes/edges not connecting properly on the edges, so I'm only using this temporarily until I have a better solution. This is also not very sustainable given the time required for API calls for the different combinations of counties being tested.
I just ran your snippet without error. Here's my log output (from the second time running it, hence everything is cached):
2022-08-01 15:32:46 Projected GeoDataFrame to +proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2022-08-01 15:32:46 Projected GeoDataFrame to epsg:4326
2022-08-01 15:32:46 Projected GeoDataFrame to +proj=utm +zone=10 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs
2022-08-01 15:32:46 Projected GeoDataFrame to epsg:4326
2022-08-01 15:32:46 Requesting data within polygon from API in 21 request(s)
2022-08-01 15:32:46 Retrieved response from cache file "cache/b546a081b3960285cd9322359d5b5beda4a7ec7f.json"
2022-08-01 15:32:46 Retrieved response from cache file "cache/61d94f5874162ffef152b88b43faf02675b43ff2.json"
2022-08-01 15:32:46 Retrieved response from cache file "cache/70de3b142e5dd9720b41f024c8b9319205d6313d.json"
2022-08-01 15:32:46 Retrieved response from cache file "cache/753bb249b47e4fac2706729b986412e99968b1e6.json"
2022-08-01 15:32:46 Retrieved response from cache file "cache/28c6041c9396c1b5333a06a747a79f8498b6e2c6.json"
2022-08-01 15:32:46 Retrieved response from cache file "cache/f363982181e5a6c41d176158e68fecac55d56fe8.json"
2022-08-01 15:32:47 Retrieved response from cache file "cache/4c0efbc6d05d4b5c2e3d6861177c865f3d1fc35c.json"
2022-08-01 15:32:47 Retrieved response from cache file "cache/99e480a1082e178309d09504e426e0677faefcba.json"
2022-08-01 15:32:47 Retrieved response from cache file "cache/6c2ffa7e9b86d5cfe9a8de266d51ee6041b934a6.json"
2022-08-01 15:32:47 Retrieved response from cache file "cache/4b656eb4e0ae0e70e1a58db5d877c07e18581db5.json"
2022-08-01 15:32:47 Retrieved response from cache file "cache/e89168dd95b68c067aedcbea48c1536d09b9cf08.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/7fa107317ebd6f3fe84a49a038b66cbc807933b5.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/868368b2d63a7e7528b99f47a2a36dfb05e35e3e.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/1e6824abfcfc595239852421faa40e190ea8f3b5.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/45d09f4c40d05d878758bedd4886ea7ea34a20d8.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/79884905de93bbd713780d9af3c124f001c6cf1c.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/8d507b17ad23b01f6ba800ec54c247814e388d2c.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/a41592e1f4b53280ab68d2703c31f30908ee76b7.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/5722f4579685b0f2629c60d6a9cad2c87b3882f1.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/672df518e1b908dbd4599c47a6525912301c7ddc.json"
2022-08-01 15:32:48 Retrieved response from cache file "cache/e14e5258c75a032691a9afcf334218f54bdb3749.json"
2022-08-01 15:32:48 Got all network data within polygon from API in 21 request(s)
2022-08-01 15:32:48 Creating graph from downloaded OSM data...
2022-08-01 15:33:02 Created graph with 1501962 nodes and 2799653 edges
2022-08-01 15:33:10 Added length attributes to graph edges
2022-08-01 15:33:10 Identifying all nodes that lie outside the polygon...
2022-08-01 15:33:33 Created nodes GeoDataFrame from graph
2022-08-01 15:33:50 Created r-tree spatial index for 1501962 geometries
2022-08-01 15:33:54 Identified 1490727 geometries inside polygon
2022-08-01 15:34:04 Removed 11235 nodes outside polygon
2022-08-01 15:34:04 Truncated graph by polygon
2022-08-01 15:34:06 Begin topologically simplifying the graph...
2022-08-01 15:34:24 Identified 223012 edge endpoints
2022-08-01 15:34:55 Found 2 edges between 65430220 and 9289642713 when simplifying
2022-08-01 15:35:08 Simplified graph: 1490727 to 223012 nodes, 2777282 to 539976 edges
2022-08-01 15:35:09 Identifying all nodes that lie outside the polygon...
2022-08-01 15:35:12 Created nodes GeoDataFrame from graph
2022-08-01 15:35:14 Created r-tree spatial index for 223012 geometries
2022-08-01 15:35:15 Identified 221995 geometries inside polygon
2022-08-01 15:35:18 Removed 1017 nodes outside polygon
2022-08-01 15:35:21 Removed 34 isolated nodes
2022-08-01 15:35:26 Got largest weakly connected component (219633 of 221961 total nodes)
2022-08-01 15:35:26 Truncated graph by polygon
2022-08-01 15:35:27 Counted undirected street segments incident on each node
2022-08-01 15:35:27 graph_from_polygon returned graph with 219633 nodes and 534196 edges
This is on a Mac with Python 3.10 and OSMnx 1.2.1.
Thank you for the response. Indeed, I tested it on my personal computer and it ran fine. Same code, same conda requirements (OSMnx 1.2.1 on Windows 11 21H2 build 22000.795). I also tested it on another machine with success (OSMnx 1.2.1 on Windows 10 21H1 build 19043.1766).
However, on the problematic machine, trying with a fresh conda environment (again, with the same requirements) still results in the same issue. This occurs even when using the same cache from the successful runs on the other machines. It runs fine in a docker on this same machine.
Let me know if you want me to try anything or to provide any additional info. Otherwise, feel free to close this issue if you think it's an isolated case.
I'll have access to my Ubuntu machine again in a few days. We can leave this issue open until I test it on that machine, in case there's a linux-related issue. However, even if there is, it sounds like it would be related to some dependency in the stack rather than OSMnx itself.
I'm unable to reproduce this on Ubuntu 22.04 either. I'm going to close this as it seems to be an isolated case that I cannot reproduce.
Making this report based on my post on StackOverflow (now deleted following the discussion in this thread) as I believe this may be a bug.
Problem description I'm preparing code to download street network for the Bay Area based on the following example. My version of the code (with small modifications) is at the end of this report. The code returns an error for both, the original example and my version, given the entire Bay Area. However, it works okay if we comment out some of the counties as such:
I'm not sure what the issue is, as it seems inconsistent. Uncommenting any of San Mateo, Santa Clara or Alameda in the dictionary above results in the code erroring out too for example. Any suggestions on how to go about resolving this? This is not exclusive to the Bay Area, but seems to happen for other cities when combining counties in the same fashion.
Here's the error (with the last few relevant lines from log):
Environment information
Reproducible example (OSMnx 1.2.1)