What is GeoJSON?

      GeoJSON is a specification for storing and representing geographic data in JSON format. If you have JSON data that contains latitude and longitude values, the data needs to be converted to GeoJSON format before you can view it on a map.


      What is an isochrone?

      An isochrone, in this context, is a shape that shows all locations that are reachable within a set travel time limit. For example, the image below shows all the locations you can reach within 45 minutes assuming you depart Times Square, Manhattan at 1pm on a weekday.

      How do you create an isochrone?

      In this blog, we use the TravelTime API to create an isochrone shape. The API’s TimeMap feature returns JSON response. We can convert JSON to GEOJSON using the steps below. Take a look at an example TimeMap response.

      Example of an isochrone shape returned by the TravelTime API using TimeMap

      The response is made up of:


      This is the term to describe the makeup of the isochrone. The lat/long coordinates describe the linear ring of the isochrone. This defines the points that should be joined up to define the isochrone shape.



      This is the term to describe the areas within the total isochrone shapes that aren’t reachable. The coordinates of the cut out are given to the user.


      To get more information on how to create an isochrone using the TravelTime API take a look at this tutorial

      How to convert a TravelTime TimeMap JSON response to GeoJSON

      The TimeMap endpoint returns an array of shapes for each successful search queried in the request. The shape consists of a linear ring of coordinates for the shell of the polygon and an array of linear rings for holes within the polygon. Coordinates are in a { ‘lat’: <latitude>, ‘lng’: <longitude> } format. See full JSON response here.

      In GeoJSON this can be represented as MultiPolygons inside a FeatureCollection. Firstly we need to convert coordinates to a [<longitude>, <latitude>] format.

      Converting coordinates in a linear ring

      This can be achieved by mapping each coordinates object in the response to an array of coordinates:

      Converting the array of shapes into a MultiPolygon

      For this we iterate through all shapes, converting their linear rings with the previous function to convert coordinates, combine all rings into a single array where the first element of the array is the shell and put all resulting rings into a MultiPolygon object as specified in the GeoJson specification.

      Converting the complete response

      If the response has not yet been parsed from JSON we need to parse it first. Then we iterate through each result and convert their shapes into a MultiPolygon with the function above. Finally, we put the array of resulting MultiPolygons into the FeatureCollection object and return it. The result of this function can be converted back to a JSON string and written to a file or sent to another service as input.

      Complete code

      The complete code for reference:

      Converting JSON to GeoJSON in Python

      Here is an equivalent code snippet in Python:

      Viewing GeoJSON within an application

      After the response has been converted, it can be viewed using a number of applications.

      GeoJSON is compatible with several mapping API’s, including:

      • Leaflet
      • Google
      • Open Layers

      It is also compatible with other open source software, including:

      • QGIS
      • PostGIS
      Isochrone maps
      Location APIs

      Share this article

      Create travel time polygons and matrices with the TravelTime API

      Build travel time polygons and catchment areas with the TravelTime API.