Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sc functionality on large networks #211

Closed
jucardwell opened this issue Jun 23, 2023 · 5 comments
Closed

sc functionality on large networks #211

jucardwell opened this issue Jun 23, 2023 · 5 comments

Comments

@jucardwell
Copy link

Looking for tips on utilizing dodgr sc functionality with OSM networks that are too large to extract using osmdata. Is there functionality to translate an sf output from osmextract to sc format within dodgr? Or is the best practice to make many small requests to osmdata? For context, I am extracting a road network for an entire US state

@mpadge
Copy link
Member

mpadge commented Jun 23, 2023

Thanks for asking @jucardwell, Short answer: You can't do it directly in R. The overpass server behind osmdata won't deliver data that large, and all other options (sf, osmextract, ...) read through GDAL which strips away all of the information needed for routing. The good news: You can do it with osmium-tool. My general procedure for that is:

  1. Download OSM data in pbf format from geofabrik
  2. Cut to desired are using osmium extract and generate a pbf output
  3. Filter to desired way types using osmium tags-filter and generate a .osm output (by simply specifying ".osm" as the suffix on the object file after -o).

You can then use osmdata to read that in and convert to SC format, and then to construct a network with dodgr.

Your challenge will likely be selecting an appropriate sub-set of key-value pairs. I presume you're likely interested in routing motorized vehicles (but correct me if i'm wrong!), so guess you'll only need "highway", and I'd initially recommend trying some minimal set like `highway=motorway|motorway_link|trunk|trunk_link|primary|primary_link". See how that goes, and expand to lesser road categories if you can/want.

Feel free to ask any other questions, or to close the issue if that helps you. Thanks

@jucardwell
Copy link
Author

Got it, thanks. I think I have the file extracted, filtered, and in .osm format but receiving a bad request error when using command osmdata_sc(). Is that the correct command for reading in?

@mpadge
Copy link
Member

mpadge commented Jun 26, 2023

You need to pass the .osm file as the "doc" parameter: x <- osmdata_sc(doc = "mydata.osm"). (The query parameter is optional.) It should then make no external calls at all, so you should never see anything like a bad request error.

@jucardwell
Copy link
Author

Hi @mpadge, thanks for all the help so far.

I've been able to construct an sc network for my area of interest and weight the graph. However, I'm facing fatal error/ R abort when executing dodgr_times(). Figured it could be a computational limit on my local machine, so I also attempted running it on a computing cluster and received a segfault error (*** caught segfault ***
address 0xfffffffdf871f020, cause 'memory not mapped'). I've also tried disabling parallel processing and received the same error. I'm wondering if you can think of an approach that would limit memory usage (for instance, iterating through each routing request), or if you think it is the pure size of the sc network that causes the error. For context, I am routing from approx 7,000 locations to approx 100 locations and dodgr_times() executes successfully on the same size network in sf format.

Thanks for any thoughts

@mpadge
Copy link
Member

mpadge commented May 16, 2024

@jucardwell I'm going to presume this is now dormant and close, but feel free to ask any further questions.

@mpadge mpadge closed this as completed May 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants