Geographic Information Systems Asked on January 5, 2022
I already managed to return geometries of Isochrones using the API as follows:
https://sampleserver.com/otp/routers/myrouterid/isochrone?algorithm=accSampling&mode=WALK&walkSpeed=1.11&cutoffSec=900&precisionMeters=10&date=2017/11/22&time=14:00:00&maxWaitingTime=20&maxWalkDistance=1000&transfers=5&offRoadDistanceMeters=100&fromPlace=44.097088542141,14.5792197160854
Now I’d like to also return requested routes via OpenTripPlanner REST-API as line geometry which can be loaded into a GIS.
https://sampleserver.com/otp/routers/myrouterid/plan?fromPlace=44.170960,14.5311114&toPlace=44.127964,14.603506&time=14:00:00&date=2017/11/22&mode=CAR
returns the route as JSON, but not its geometry.
I already tried different URLs as described in the API-Docs here: http://dev.opentripplanner.org/apidoc/1.0.0/resources.html, but so far I wasn’t able to return a route geometry.
Is it possible to return the geometry of a route using OpenTripPlanner API and if so, how?
Based on my Plugin I made a responsive processing tool for QGIS, which does exactly what I need, but cannot post it here due to Body is limited to 30000 characters; you entered 32412.
, so just follow the link....
PS: I still have an open question to improve it, in case you know the answer: Changing feature attribute just after adding via QgsFeatureSink
Answered by MrXsquared on January 5, 2022
I basically wrap this thing and added in an existing python site-package called rasta with an easy-to-use class. Here is an example:
from rasta.navigate_with_otp import GetOtpRoute
my_otp_nav = GetOtpRoute(
start_coord="48.81941, 9.27212",
end_coord="48.78153, 9.20517",
time="03:00:00", # Optinal, if not provided then it uses the current time
date="2020/12/25", # Optinal, if not provided then it uses the current date
MAPBOX_API_KEY=MAPBOX_API_KEY, # Necessary, only if you want to visualize in the map
output_map_path="temporary_map", # To save the output kepler map
mode="TRANSIT,WALK" # If not provided, then assuime the " Transit and walk"
)
A notebooks is also available here, which shows dataframe and visualisation as well.
Answered by ikespand on January 5, 2022
I have developed a PlugIn for QGIS which can do this: https://plugins.qgis.org/plugins/OpenTripPlannerPlugin/. It decodes the polylinestrings as mentioned in my first answer.
Your OTP-Server needs to be accessible without a proxy or authentification; enter its URL including the part to the router in "General Settings" tab (e.g. http://localhost:8080/otp/router/myrouter/
)
Then choose your one or two point layers containing the starts and stops. Note the checkbox "Create only Routes for matching Fields" if you wish to create a matrix or create all routes from source to target. Then choose your desired settings and hit run.
Answered by MrXsquared on January 5, 2022
If you are an R user you could use https://docs.ropensci.org/opentripplanner/
You can then save out the results in a QGIS compatible format
otpcon = otp_connect()
mydata = otp_plan(otpcon, from, to)
sf::write_sf(mydata,"mydata.gpkg")
Answered by falcs on January 5, 2022
plan
resource returns an encoded polylinestring.
This can be turned into 'actual geometry' using scripts from this Stack Overflow question: https://stackoverflow.com/questions/9217274/how-to-decode-the-google-directions-api-polylines-field-into-lat-long-points-in/22737305
There are working ports for python, VBA, Java, ...
These can be used to create a GeoJSON file of the route.
Answered by MrXsquared on January 5, 2022
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP