I already managed to return geometries of Isochrones using the API as follows:


Now I'd like to also return requested routes via OpenTripPlanner REST-API as line geometry which can be loaded into a GIS.


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?


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 | |

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

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. Note that it is still experimental, but apart from a freezing GUI on heavy load it is working fine.

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.

enter image description here

| 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.