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

Explore partially reproducing od2net approach #2

Open
Robinlovelace opened this issue Jan 11, 2024 · 15 comments
Open

Explore partially reproducing od2net approach #2

Robinlovelace opened this issue Jan 11, 2024 · 15 comments

Comments

@Robinlovelace
Copy link
Contributor

In conversation with @HemantSharmaTP the idea is to prototype the approach developed by @dabreegster in R, just for fun.

We really like the global applicability of this, example from Leeds:

image

https://urban-analytics-technology-platform.github.io/od2net//interactive.html#16.52/53.810078/-1.542723

@HemantSharmaTP
Copy link

Screenshot 2024-01-11 at 3 43 24 PM

That's how this looks in New Delhi. it's much more crowded though.

@Robinlovelace
Copy link
Contributor Author

Also: not tied to R. Could use another language, key thing is ease of iteration. Maybe that it's worth contributing directly to the od2net project but for the use case we're talking about I suspect it will be quicker to rapidly prototype in a new repo. R/Python/other fine by me though!

@dabreegster
Copy link

What can you share about the use case, so I can understand od2net's shortcomings?

@Robinlovelace
Copy link
Contributor Author

What can you share about the use case, so I can understand od2net's shortcomings?

Use case: being able to generate route networks from the command line in a programmable and easy to extend way. I think that is doable with od2net, we'd just need to learn a lot of Rust or work on bindings to R/Python. Could be that working on Urban-Analytics-Technology-Platform/od2net#28 is a quicker way to what we're after (a way to generate route networks in a way that's flexible and easy to modify/automate/extend for sustainable transport planning) that starting from scratch. Happy to have a go at a basic R (or even Python further outside my comfort zone) interface, especially following @JosiahParry's impressive work in this space but not really sure where to start.

@Robinlovelace
Copy link
Contributor Author

So not really about shortcomings of od2net, more our ability to contribute to it. That is not fixed and we can think about contributing here... I think validation and generating plausible baseline scenarios and scenarios of change would be a good starting point, validated against counter datasets (which is where some data science/stats could come in handy).

@Robinlovelace
Copy link
Contributor Author

Another use case: refactoring the backend code that generates the data shown in www.npt.scot

@dabreegster
Copy link

I don't think we really need bindings in another language to use od2net. You have to generate input data and config, then call one command to run od2net and produce output files. https://github.com/Urban-Analytics-Technology-Platform/od2net/blob/main/examples/oneshot/oneshot.py is a recent example that extracts a bounding box from Overpass and plugs in a basic OD pattern.

I started od2net largely to help stop reinventing the wheel with projects like NPT. If the current examples in there aren't adequate or the docs aren't enough (very true), I'd like to improve them.

@dabreegster
Copy link

I think validation and generating plausible baseline scenarios and scenarios of change would be a good starting point, validated against counter datasets

Agreed. I don't think any of those tasks belong in od2net itself; it's just a tool to do one particular calculation. The larger validation exercise or generating good OD pattern input is up to a per-use case project.

@Robinlovelace
Copy link
Contributor Author

Happy to give it a go, currently hitting

./run_all.sh 
Checking dependencies
+ run_example york
+ echo 'Running example york'
Running example york
+ cd york
+ rm -rf input/ intermediate/ output/
+ python3 setup.py
Traceback (most recent call last):
  File "/home/robin/github/people/dabreegster/od2net/examples/york/setup.py", line 62, in <module>
    run(["mkdir", "-p", "input"])
NameError: name 'run' is not defined

on my laptop on latest version of main. If we create a minimal input dataset for Leeds would that be a good starting point? Creating an example/leeds could be a good way to get my head round it, debugging and providing feedback as I go.

Agreed, would be great to have a flexible tool that gets around reinventing the wheel.

@Robinlovelace
Copy link
Contributor Author

od2net would be great as the modular + flexible network generation part of the wider process, all in on that, if I can get it working!

@dabreegster
Copy link

That's the same Python import error you've hit before. (I'll try and look at it tomorrow, but no promises with workload) You can also forget about the example scripts and just generate input yourself in the way that's comfortable.

@JosiahParry
Copy link

since od2net is made available as a lib we could, in theory, create R bindings to avoid general python dep tomfoolery, right? I havent had a chance to dive into this much

@dabreegster
Copy link

dabreegster commented Jan 11, 2024

I think the right way to call od2net is as an executable. Calling the Rust API directly isn't really helpful. The steps to using it are conceptually:

  1. Create input files however you like -- an osm.pbf extract, a .geojson file with points for origins and destinations, optionally a .csv for some origin/destination data, a config.json specifying some settings
  2. cargo build the executable, then run and point to config.json
  3. Use the output files

The Python examples are just doing step 1, and additionally taking dependencies on other tools like ogr2ogr and osmium. You can ignore the Python examples or the way they do things entirely if you like.

Edit: and I can wire up Github actions to build the executable for Mac/Linux/Windows if cargo build in step 2 is a hassle

@dabreegster
Copy link

I dunno if I've linked it, but https://github.com/Urban-Analytics-Technology-Platform/od2net/blob/main/docs/tutorial_new_area.md should be up-to-date and relevant here

@Robinlovelace
Copy link
Contributor Author

od2net executable sounds fine, qgisprocess is close to best practice in terms of how to interface.. Open to ideas and keen to learn!

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

4 participants