This tutorial helps you to:

  1. Identify if a point falls within a travel time polygon area
  2. Calculate travel times to every point within a polygon area
  3. Draw the travel time polygon if you require a visualisation

It includes code examples in many languages including Python, R, Java and JavaScript

At the end of the tutorial we will also include answers to the most important questions:

  1. How much will it cost me?
  2. How many polygons can I create?
  3. Which transport modes can I use to do this?
  4. Where do you get your data?
Blog gif

Contents

      Example use case

      A retailer wants to filter their database of 500 customers to see how many fall within a 30 minute drive of their newly proposed ‘Times Square, New York’ store location. We’ll use this example throughout this tutorial, but you can adjust your request to suit your needs.

      Filtering point in a polygon & calculating travel times to every reachable point

      In our example, the retailer finds out that 375 of their 500 customers in their database fall within a 30 minute drive, and 125 are unreachable in this time limit. The retailer can see the exact amount of time from the store to the 375 reachable customers. For the remaining 125, there is no value calculated.

      To get this information, we use the Travel Time Matrix API, using the time filter endpoint. The request requires the user to specify some parameters:

      • Transport mode
      • Departure time or arrival time. If you don't want a specific time, you can use a range, explore this option more here.
      • Location lat/long
      • Travel time

      In our example we've chosen:

      • Driving
      • Departing at 3pm
      • 'Times Square, New York' as our location
      • 30-minute travel time catchment area

      The snippet above is a cURL request. We've included some examples for the most common coding languages. The code snippets assume that customers data is read from the 'custom.csv' file. However, it could be your designated database, CRM or other system.

      Point in polygon Java

      Point in polygon R

      Point in polygon Python

      Point in polygon JavaScript

      Drawing the travel time polygon

      The snippet below shows the API request needed so that the retailer can draw a 30 minute drive time area from 'Times Square, New York'. If you need a more detailed tutorial on how to visualise this shape on a map, please follow this tutorial.

      This uses the Isochrone API. The parameters used in this request are the same as the Time Filter endpoint request above.

      FAQs

      1. How much will it cost me?
      2. How many polygons can I create?
      3. Which transport modes can I use to do this?
      4. Where do you get your data?
      Blog_CTA
      Distance matrix

      Share this article

      Create travel time polygons and matrices with the TravelTime API