Tutorials and hands-on lessons for learning

Finding the nearest distance (one to many)


Calculating the distance between points is useful if you only have two points (one-to-one), but what if you have a collection of points and want to compare distances to a single point (one-to-many)? Nearest analysis calculates the distance between each point in a feature collection to a reference point and returns the point from the feature collection that is nearest to the reference point. This type of analysis can be used to help users find the nearest location or service. For example, locating the nearest museum or coffee shop or helping patients with COVID symptoms locate the nearest testing facility.

Your Turn

Complete the following tutorial:

Find the nearest point with turf.nearest()

Review questions

  1. What is the difference between nearest analysis and point distance analysis?
  2. Describe how each of the following tutorials calculates the nearest point:

       a. Find the nearest point with turf.nearest()
       b. Find the nearest points with turf.distance()
Was this page helpful?