PROBLEM

Unable to find the nearest location within the same layer in ArcGIS Online

Last Published: April 25, 2020

Description

In ArcGIS Online, the Find Nearest tool requires two inputs: an input feature layer, and near feature layer. Both input layers cannot be the same layer. In some instances, it may be desirable to find the first nearest location within the same layer. This can be done by duplicating the layer in the map viewer and using the duplicated layer as one of the input layers. However, when running the tool with both the layer and the duplicated layer as inputs, the data in the table shows zero values for the distance. In some cases, the following error is returned:

Error:   
Find Nearest failed.
Find Nearest failed.

Cause

This issue occurs because the closest point identified by the tool is identical to the origin point. This results in null linear distance geometry, hence no features can be created.

Solution or Workaround

As a workaround, set the limit number of the nearest locations to two (2) locations before running the Find Nearest tool, and filter the results with a linear distance of more than zero. Follow the steps below:
  1. Set the limit number of nearest locations to two locations.
    1. Open the Find Nearest tool by clicking Analysis > Use Proximity > Find Nearest.
    2. Select the layer as the input feature layer, and the duplicate layer as the near feature layer.
    3. Set Limit the number of nearest locations to 2.

      Set the Limit the number of nearest locations to two locations
       
    4. Click Run Analysis. Two new layers are created in the Contents pane.
  2. Filter the results with a linear distance of more than zero.
    1. View the table of the output layer containing the connecting lines between the nearest locations.
    2. In the table, click the Options button > Filter.
    3. Select Straight Line Distance for the first drop-down field.
    4. Select is greater than for the second drop-down field.
    5. Enter 0 as the value in the text field. Click Apply Filter. The first nearest location and its distance value are displayed in the table.

      The first nearest location and its distance value are displayed in the table.

Article ID:000015937

Software:
  • ArcGIS Online

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic