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
Source layer – stores data to which the target layer will be referring.
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.
Units – format that should be used to save the distance in target’s distance column/s
Target layer – records from this layer will be matched to the nearest records from the source.
Distance Column/s – specify column/s where the distance values to the first/second/third etc. nearest source record should be saved to.
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
Â
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.
The Source Id column will point at School_name column which will allow me to save school name value of the nearest source record.
I set my units to metres as format for values saved in target’s Distance Column/s
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
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.
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.
Â