Assign Nearest

Preparing the data

In this guide, I will be working on two layers, one storing schools’ data and another containing students’ data. Assign Nearest tool will be used to update students’ records with information about nearest school name and distance between the records. With that said, I have added two columns to my students’ layer which will be updated during the process: nearest_school and nearest_distance.

You can also specify columns for up to the fifth nearest record from the source layer, however, for each subsequent distance, another pair of new id & distance columns will be required.

 Assign Nearest tool will perform batch updates on specified columns, therefore, please make sure that the columns are selected correctly and do not contain data as these will be overwritten during the process.

Settings up Assign Nearest tool

  1. Source layer – stores data to which the target layer will be referring.

    1. Source Id column – stores data that will later be copied to target layer id column/s as information on which record from source was matched as the first/second/third etc. nearest.

    2. Units – format that should be used to save the distance in target’s distance column/s

  2. Target layer – records from this layer will be matched to the nearest records from the source.

    1. Distance Column/s – specify column/s where the distance values to the first/second/third etc. nearest source record should be saved to.

    2. Id Column/s – specify column/s where the Source Id column value for the first/second/third etc. nearest source record should be saved to.

 

Example

 

  1. As mentioned at the start of the guide, I will be using two layers for this example: Schools and Students. In Assign Nearest tool, the Schools layer will be set as source because I have to determine distance from each student to the nearest school and not the other way around.

    1. The Source Id column will point at School_name column which will allow me to save school name value of the nearest source record.

    2. I set my units to metres as format for values saved in target’s Distance Column/s

  2. The Target layer is set to Students, Assign Nearest tool will take each record from this layer and match it with nearest record from the Source layer

    1. I will be only saving distance values for the first nearest record from source layer, however, if you would like to know what is the distance to second/third etc. nearest record from the source layer, please select columns in corresponding fields that should be used to store that data.

    2. As with distance fields, I will be saving Id data only for first nearest record from source layer, however, if you would like to know what is Id value of the second/third etc. nearest record from the source layer, please select columns in corresponding fields that should be used to store that data.

Â