2

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?

1

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.

| improve this answer | |
1

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")
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.