GIS is very useful is analyzing spatial relationship between features. One such analysis is finding out which features are closest to a given feature. QGIS has a tool called ‘Distance Matrix’ which helps with such analysis. In this tutorial, we will use 2 datasets and find out which points from one layer are closest to which point from the second layer.
- Importing CSV file to QGIS.
- Understanding and using the Distance Matrix tool.
- Using table joins to merge the result of the analysis with the source data.
Let’s get started. In this tutorial, we will walk through the process and answer this question. Given the locations of all known significant earthquakes, find out the nearest populated place for each location where the earthquake happened.
Follow the instructions in this tutorial to import the Significant Earthquake CSV file to QGIS. Also open the Natural Earth populated places layer using Layer → Add Vector Layer.
In the screenshot, each green point represents the location of a significant earthquake and each blue point represents the location of a populated place. We need a way to find out the nearest point from the populated places layer for each of the points in the earthquake layer.