-
Notifications
You must be signed in to change notification settings - Fork 10
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
Multimodal access egress script #119
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the motivation for stepping? Is it much faster than finding the closest and it's distance for every stop?
Just to confirm I understand this correctly, re question by @fredshone : you build a So since you probably end up matching multiple PT stop nodes with their closest link at every step iteration, you end up having to build the tree and do the spatial join fewer times than if you did it separately for every PT stop node, and so it should be faster? (I'm assuming building a tree + doing spatial join is slower than just doing a spatial join with a larger data frame) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is really sleek! 👍
@fredshone I see it as the first step to finding a closest link (LineString) to a point. One day when we want to be more precise and find the closest link we can extend this by first: point-ising the links (split the linestring into series of points) and then: finding which point is the closest (be able to get the precise distance then) and what link it belongs to for snapping. It's the least effort approach, using what have already been built for PT snapping with genet. We have a pretty snappy method for finding point - point closest neighbour and distance that would work well with the extras I described above. (cc @ana-kop for your reference: this is the snappy method I mean) |
@ana-kop the spatial tree is built only once as it's the most expensive process. The stops grow their neighbourhoods by step_size until they hit some links. |
Added some extras to this script and renamed it.
e.g. <stopFacility id="910GCLPHMJ1" x="527206.6904087012" y="175500.35337682866" name="Clapham Junction" linkRefId="5221366977632357115_5221366977632357115">
<attributes>
<attribute name="accessLinkId_car" class="java.lang.String">5221366976716902339_5221366976715137595</attribute>
<attribute name="carAccessible" class="java.lang.String">true</attribute>
<attribute name="car_distance_catchment_tag" class="java.lang.String">100.0</attribute>
<attribute name="accessLinkId_bike" class="java.lang.String">5221366976716902339_5221366976715137595</attribute>
<attribute name="bikeAccessible" class="java.lang.String">true</attribute>
<attribute name="bike_distance_catchment_tag" class="java.lang.String">100.0</attribute>
<attribute name="walkAccessible" class="java.lang.String">true</attribute>
</attributes>
</stopFacility> Re-ran an updated matesto test pipeline: Update: - id: genet-pt-rail-car-bike-walk-access-egress
uses: docker://758645626094.dkr.ecr.eu-west-1.amazonaws.com/genet:KasiaKoz-multimodal_access_egress
args: [
"intermodal_access_egress_network.py",
"--network", "working-dir/londinium/2_genet_simplified/network.xml",
"--schedule", "working-dir/londinium/2_genet_simplified/schedule.xml",
"--vehicles", "working-dir/londinium/2_genet_simplified/vehicles.xml",
"--projection", "epsg:27700",
"--pt_modes", "rail",
"--network_snap_modes", "car,bike",
"--teleport_modes", "walk",
"--step_size", "50",
"--distance_threshold", "200",
"--output_dir", "working-dir/londinium/3_genet_mm_access_egress"
]
dir: / |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff!
* add todos * refactor additional attrib check method * extract/isolate additional attrib save method * extract/isolate general attrib save method * refactor/generalise general attrib save method * allow saving additional attribs for stops * allow saving additional attribs for routes * allow saving additional attribs for services * allow saving additional attribs for schedule * (add missing file) allow saving additional attribs for schedule * general functions to prepare and check for optional and required xml attributes for nodes, links and stops * fix var import oopsie * add saving arbitrary additional attributes for network nodes * tidy up consolidating stop projections * refactor inputs_handler/outputs_handler * refactor test file names inputs_handler/outputs_handler * add read additional node attributes from xml * refactor and add additional attrib read placeholders for schedule elems * add additional attrib read for stops * add additional attrib read for routes * add additional attrib read for services * add additional attrib read for schedule * extend additional attrib read for global network attribs * lint cleanup * fix notebook import * more notebook fixes * fix up network level attributes, add read * change to nested dict support for stop/route/service attribute setting * tidy up todo * add attributes as an always present attribute * fix disappearing attribute values post save * change simplified tag * possible fix for pt attributes being read as None * Magical java typing for additional attributes (#124) * add assuming java types for additional attributes when writing to xml * add assuming python types for additional java-typed attributes when reading from xml * fix lingering dependence on long form attributes * update notebooks with simple form attributes * extra fixes, add dtype param to road pricing to match with OSM ID dtypes * increase code coverage * address PR comments * PR update: enable forcing long form when reading matsim networks * lint * address PR comments * Multimodal access egress script (#119) * add example script for snapping pt stops to other parts of the network * warn of unsnapped stops if distance threshold reached prematurely * relax condition * add handling multiple network modes and teleport (access only) modes
Adds a script that finds a link of mode
X
in the nearest neighbourhood of a PT stop (the stops can, but need not be filtered based on PT modes using the stops).Works with a single mode in the
network.xml
graph, e.g. car. This results in new, additional attributes for relevant PT stopsfollowing convention started in the multimodal access egress test data here. The param
distance_catchment
retains information about how far the link is (though it's not the exact distance to link).Method:
Each stop of interest grows by
step_size
(metres) until it intersects with a link of specified mode, or until thedistance_threshold
is reached (if this parameter is set). Often there are multiple choices for links intersecting with stop neighbourhood. Right now we select the first link on the list, one day we might be more discerning about which link is the access/egress point of a mode to/from a stop.Test:
Tested with a Matesto pipeline for Londinium [PR] which generates the network from osm and gtfs inputs with puma, simplifies with genet and (the new thing we're testing here) uses genet to find nearest car links to rail stops. This then gets run using MATSim with appropriate configuration.
MATSim outputs show an agent driving to a PT stop and using a PT service: