3.4. Proximity analysis

We will now focus on operations involving point layers. Please note that QGIS, when clipping a Point layer, also converts its geometry type to MultiPoint. This geometry type is not suitable for some of the functions we will use in the next step and therefore we will first see how to convert the geometry type back to Point.

../_images/3.4_MultiPoint.PNG

Fig. 3.4.1 In the information of the places_clip layer we can see that its geometry is MultiPoint

3.4.1. Convert geometry type

Available at Processing Toolbox->Vector geometry->Convert geometry type, it provides an algorithm that allows to convert the MultiPoint features to single Point features. To do so, the input parameters are:

  • Input layer: the point layer whose geometry we want to convert. In this example we use the places_clip layer
  • New geometry type: select Centroids
  • Converted: the path and the name of the output vector layer. Note that if left empty a temporary layer will be created
../_images/3.4.1_convert_geometry.PNG

Fig. 3.4.1.1 Convert geometry function window

../_images/3.4.1_Point.PNG

Fig. 3.4.1.2 Now the places_clip layer’s geometry is MultiPoint

In order to continue with the following functions, please convert the geometry type also for the natural_clip point layer.

Note

After you are done with the conversion, you can remove the previous point layers and include in the project only the new ones.

3.4.2. Average Nearest Neighbor

Available at Processing Toolbox->Vector Analysis->Nearest Neighbour Analysis, it provides a function that performs nearest neighbor analysis for a point layer. The output is generated as an HTML file with the computed statistics. We perform the Nearest Neighbor Analysis with the natural_clip_point point layer; the input parameters are:

  • Input layer: the natural_clip_point layer
  • Nearest Neighbor: the path and the name of the output HTML file. Note that if left empty a temporary file will be created
../_images/3.4.2_nearest_neighbor.PNG

Fig. 3.4.2.1 Nearest Neighbor Analysis function window

Once the operation is done, you can open the HTML file containing the results and you will see information about the Observed mean distance, Expected mean distance, Nearest neighbour index, Number of points, and Z-Score.

../_images/3.4.2_nearest_neighbor_result.PNG

Fig. 3.4.2.2 The HTML result when opened in the browser

We now see how to calculate the nearest feature to a given point or set of points in QGIS. We distinguish between distances from point to point, and from point to a line or polygon layer.

3.4.3. Distance from point to point

Available at Processing toolbox->Vector analysis->Distance to nearest hub (points), it provides an algorithm that computes the distance between point features taken as the origin and their closest point destination. In this case, we will calculate the distance from the places_clip_point layer to the natural_clip_point layer. The input parameters are:

  • Source points layer: the places_clip_point shapefile
  • Destination hubs layer: the natural_clip_point shapefile
  • Hub layer name attribute: osm_id
  • Measurement units: meters
  • Hub distance: the path and the name of the output vector layer. Note that if left empty a temporary layer will be created
../_images/3.4.3_distance_points.PNG

Fig. 3.4.3.1 Distance from point to point function window

The result is a copy of the places layer, but each point feature has two additional attributes: the id of the nearest natural point feature (HubName) and the distance from it (HubDist), as you can see from its attribute table:

../_images/3.4.3_distance_points_result.PNG

3.4.4. Distance from point to layer

Available at Processing Toolbox->Vector analysis->Distance to nearest hub (line to hub), it provides an algorithm that computes the distance between point features taken as origin and their closest destination line or polygon feature.

Note

Distance calculations are based on the centroid of the line or polygon features.

In this case, we calculate the closest forest to each place. To do so, we select all the forests from the landuse_a_clip layer:

  • Right-click on the landuse_a_clip layer in the Layers panel and click on Open attribute table
  • Click on the Select features using an expression button
  • In the window, write the following expression: "fclass" is 'forest', and then click “Select features”
../_images/3.4.4_select_expression.PNG

Once we have selected all the forests from the landuse_clip layer, we can run the Distance to nearest hub (line to hub) function. The input parameters are:

  • Source points layer: the places_clip_point layer
  • Destination hubs layer: the landuse_a_clip layer, considering only selected features
  • Hub layer name attribute: osm_id
  • Measurement units: meters
  • Hub distance: the path and the name of the output vector layer. Note that if left empty a temporary layer will be created
../_images/3.4.4_distance_polygons.PNG

Fig. 3.4.4.1 Distance from point to layer function window

The result is a line layer representing all the distances from each places point feature to the nearest forest feature.

../_images/3.4.4_distance_polygons_result.PNG