following this tutorial I set up a OpenTripPlanner (version 0.11.0) stand alone server. It works very well at


and for example at


returns a routes json.

Now I'd make rest api request (I'm interesting to Isochrone api). I try return isochrone geometry as a set of GeoJSON polygons at the url specified at this link but doesn't work.

Can you suggest the right url to get Isochrone GeoJSON?

2 Answers 2


I am pretty much in the same boat as you but I think I have figured out how to create an isochrone. I am using version 0.18.0, not sure if that is relevant or not.

Here is where I found the example

Here's a sample isochrone that I got


It looks pretty intuitive, but I don't think the docs that I found are up to date so I have no idea how to alter the isochrone except in simple ways. Hope this is useful.


I believe it is very important what version of OTP you use as the developers are constantly making changes - I've only recently been digging into v0.19 and below are two example work-in-progress wrappers of calling OTP's isochrone API with it.

@Ravi has already given you the URL call for the isochrone API, if it doesn't work when you update the Lat/Lon for your area and enter it in your browser after launching OTP then go back to the basics and make sure your instance of OTP works - note OTP's response to the URL will be different if you include the --analyst flag (returns GeoJSON) or not (returns a shapefile) when launching OTP. I added a handful of links that have been helpful for me to @Ravi's post about OTP tutorials.

In terms of using the response below are two options that are hopefully helpful.

First, here's a Python function headed in the same direction as the below SQL query (note it just writes out the returning GeoJSON as I haven't taken the time yet to extract/read the response in Python) - I imagine some variation of this is what you'd need for web-mapping (clearly depending on what language your site's analysis is in, guess it'd be even more straightforward in javascript), but I haven't looked for examples (FYI looks like there was a web site that used OTP to create isochrones)

import json, requests
def OTPIsochroneAPI(orig, o_code, depTime = '8:00:00', cutoff = 2700, interimFolder = './interim_isochrones'):
    # create query
    baseURL = 'http://localhost:8080/otp/routers/default/isochrone?'
    qryDT = '&date=2015/12/7&time={0}&mode=WALK,TRANSIT&cutoffSec={1}'.format(depTime, cutoff)
    url = '{0}fromPlace={1},{2}&{3}'.format(baseURL, orig.lat, orig.lon, qryDT)
    # print url # print out for testing
    # get isochrone response
        response = requests.get(url)
        data = json.loads(response.text)
        #print 'response received for %s' % (str(o_code))
    # save out response
        isoFile = '{0}/isochrone_{1}_8am.geojson'.format(interimFolder, (str(o_code)))
        with open(isoFile, 'w') as outfile:
            json.dump(data, outfile)
        # TO DO: return data (plus parse and reformat for some Python spatial library) 
        print 'wrote GeoJSON for o_code %s' % (o_code)
    except IOError as (errno, strerror):
        print "I/O error({0}): {1}".format(errno, strerror)
    except ValueError:
        print "No JSON object could be decoded"
        print "Unexpected error:", sys.exc_info()[0]

Alternatively, if you're comfortable in PostGIS here's an approach I got working yesterday, note it requires Paul Ramsey's HTTP extension to be installed on your database and I only tested this on the most recent (9.5) PostgreSQL with PostGIS 2.2. Also note this is only meant to extract a single isochrone (so only one &cutoffSec= given), it would need to be adapted to extract multiple - I think with unnest() in place of (or addition to?) the json_array_elements() function

SELECT q.id_column, 
    CASE WHEN (q.resp).status = 200 -- check if response is OK
    THEN ST_SetSRID( -- creating a new geometry so need to set SRID
        ST_GeomFromGeoJSON( --OTP analyst responds with a GeoJSON
          -- but ST_GeomFromGeoJSON only handles a feature at a time 
          -- so we need to extract it, thus the functional but messy SQL below
    ELSE NULL -- there was a problem. maybe your origin was in the ocean
    END as geom_isochrone -- name your extracted geometry column
FROM ( SELECT id_column, -- grab a column identifier, then extract API response:
    || y || ',' || x || -- set your lat and lon from input data
    '&date=2015/12/7&time=8:00:00&mode=WALK,TRANSIT&cutoffSec=2700') as resp 
    FROM input_table -- your input table
) q;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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