How to Create a GeoJSON Isochrone

by Niharika Sisodia
on Sep 12, 2018

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.

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

GeoJSON-isochrone

Click 

The response is made up of:

Shells

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.

GeoJSON-isochrone

Holes

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.

GeoJSON-isochrone

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

Click

Learn more about isochrones here.

 

Related

Google Maps Drive Time Polygon Tutorial: A Guide to Driving Radius

Visualise ‘how far can I travel’ on a Google Map within a drive time limit, for example a 30 minute driving radius. Follow the free developer guide using an API or use our quick tool to build without code.

Evelina Bezubec Sep 11, 2020
READ

Creating Isochrones Using Alteryx & Tableau (Part 2)

Use isochrones for tableau spatial analysis. Create a polygon to see where's reachable within a travel time limit. Useful for site selection and more.

Chris Hutchinson May 25, 2020
READ

Creating Isochrones Using Alteryx & Tableau (Part 1)

Tutorial of how to prepare isochrone data using Alteryx to visualise using Tableau. Useful for site selection, network analysis or field management.

Chris Hutchinson May 25, 2020
READ

Creating a Population Radius Using TravelTime

Catchment area analysis: a distance-based radius doesn’t reflect accessibility to the location. TravelTime allows search based on time instead of distance.

Chris Hutchinson Feb 17, 2020
READ

How to Create Isochrones with Postman and the Traveltime API

With this Time Map endpoint tutorial using postman, you can get a list of coordinates showing a perimeter of where’s reachable within a travel time limit.

Evelina Bezubec Nov 4, 2019
READ

5 Ways to do Geocoding for Free

Discover solutions that do geocoding for free. Find out which free geocoders have the best functionality. Convert addresses and postcodes into coordinates.

Evelina Bezubec Sep 9, 2019
READ