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

Isochrone computation #311

Open
christophfink opened this issue Aug 10, 2023 · 11 comments
Open

Isochrone computation #311

christophfink opened this issue Aug 10, 2023 · 11 comments
Labels
enhancement New feature or request

Comments

@christophfink
Copy link
Member

No description provided.

@christophfink christophfink added this to the Release v0.0.6 (paper) milestone Aug 10, 2023
@christophfink christophfink added the enhancement New feature or request label Aug 15, 2023
@araichev
Copy link

araichev commented Oct 3, 2023

As a starting point, one could port the r5r isochrone code to Python.

@christophfink
Copy link
Member Author

Are you volunteering? :)

@araichev
Copy link

araichev commented Oct 27, 2023

@christophfink i'm just doing some background research at this point and not volunteering yet.
Carrying on, i see that r5 already has isochrone functionality, so maybe it's easier to port that.

@araichev
Copy link

araichev commented Oct 30, 2023

@christophfink in the meantime, i will experiment with porting the r5r isochrone code to Python.
To that end, how do i access the points of a TransportNetwork's street layer as a GeoDataFrame in analogy to this line of R code?

@christophfink
Copy link
Member Author

That would be fantastic!
Here’s my brief experiments of getting nodes out of R5’s TransportNetwork (via r5py’s)

#!/usr/bin/env python3

import geopandas
import shapely

import r5py
import r5py.sampledata.helsinki

import com.conveyal.r5

FIXED_FACTOR = com.conveyal.r5.streets.VertexStore.FIXED_FACTOR

t = r5py.TransportNetwork(r5py.sampledata.helsinki.osm_pbf, [r5py.sampledata.helsinki.gtfs])
v = t._transport_network.streetLayer.vertexStore

coordinate_pairs = zip(list(v.fixedLats.toArray()), list(v.fixedLons.toArray()))
nodes = geopandas.GeoDataFrame(
    {
        "geometry": [
            shapely.Point(lat / FIXED_FACTOR, lon / FIXED_FACTOR)
            for lat, lon in coordinate_pairs
        ]
    },
    crs="EPSG:4326",
)

nodes.sample(frac=0.5)

@araichev
Copy link

araichev commented Oct 30, 2023

Thanks @christophfink .
That worked.
And can one get the edges incident to those nodes from r5?
I want compute isochrones as buffered ways (edges) as well as concave hulls.

@araichev
Copy link

araichev commented Oct 30, 2023

My last two questions lead me to a feature request: a function or two to get the street network as a pair of GeoDataFrames of nodes and edges with supporting OSM information (OSM ID, tags, etc.) along the lines of this r5r function.

@christophfink
Copy link
Member Author

Thanks @christophfink . That worked. And can one get the edges incident to those nodes from r5? I want compute isochrones as buffered ways (edges) as well as concave hulls.

Not quite sure whether there are any look-up functions implemented, but there is an equivalent to the VertexStore: https://github.com/conveyal/r5/blob/dev/src/main/java/com/conveyal/r5/streets/EdgeStore.java

@christophfink
Copy link
Member Author

My last two questions lead me to a feature request: a function or two to get the street network as a pair of GeoDataFrames of nodes and edges with supporting OSM information (OSM ID, tags, etc.) along the lines of this r5r function.

Well, as you mentioned yourself, this is functionality that is already covered by packages such as osmnx and pyrosm. We would like to stay rather pythonic and keep redundant functionality out of the package. Of course, if you can make an excellent argument of the added value, we can talk about it ;)

(please file this feature request as a new issue)

@araichev
Copy link

araichev commented Nov 1, 2023

Yes, good point @christophfink .
Pyrosm makes the nodes and edges GeoDataFrames, but it's pretty slow to do so at ~45 s for Helsinki on my computer.
But if you build a TransportNetwork in r5py, then you've already waited to process the PBF file (~45 s on my computer), so it seems one should be able to leverage that work done to get the OSM nodes and edges, instead of having to wait again for Pyrosm to do it.
Anyway, something to think about after i finish my isochrone experiments.

@araichev
Copy link

OK @christophfink , i made two sets of isochrone prototypes and examples and put them on Github at r5py_isochrones for your perusal.
I found it much easier to experiment within a Jupyter notebook than within a fork of r5py.
If you think the prototypes are useful, then feel free to incorporate them into r5py, editing as you see fit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants