Contents:
The result layer will contain all the attributes of both the input and join layers plus a new attribute “distance” that contains the distance between the joined features. The attributes from the join layer will get a prefix (the default is “join_”, but this can be set by the user). If a join prefix is not used, attributes from the join layer that have the same name as attributes in the input layer will not be included in the output layer.
Below is a table that cross tabulates input layer (rows) and join layer (column) geometry types, and indicates the usefulness of the plugin (OK - the operation has time complexity O(NlogM) / O(NlogN), or Slow - the operation has time complexity O(NM) / O(N2), where N is the size of the input layer and M is the size of the join layer).
Layer (row: input; column: join) | Point | Line | Polygon |
---|---|---|---|
Point | OK | OK | OK |
Line | OK | OK | OK |
Polygon | OK | OK | OK |
Multi-geometries:
Layer (row: input; column: join) | MultiPoint | MultiLine | MultiPolygon |
---|---|---|---|
MultiPoint | Slow | Slow | Slow |
MultiLine | Slow | Slow | Slow |
MultiPolygon | Slow | Slow | Slow |
Looping through the features of the input layer, the nearest neighbour to each feature is identified in the join layer.
Without the use of an index, the geometry of each feature of the input layer has to be compared to the geometries of all the features in the join layer. This takes a lot of time for large datasets.
A spatial index on the join layer will normally speed up the join. QgsSpatialIndex provides the nearestNeighbor function, and this function returns the nearest neighbour(s) to a given point among the index geometries (which are approximations of the real geometries).
For input layers with geometry type point (or centroid approximation), a spatial index on the join layer will always be used.
The nearestNeighbor function of QgsSpatialIndex only works on points. By approximating non-point input layer geometries by their centroid, the spatial index can be used to speed up the join.
For layers with multi-geometries, spatial indexes are not used.
For input layers with non-point geometry type, the user can specify that the geometry centroids are to be used for the join by checking “Approximate geometries by centroids”. This means that the join will not be exact with respect to the original input layer geometries.
For join layers with geometry type other than point, the user can choose to do an inexact join based on the join layer index geometries to speed up the join by checking “Approximate by index geometries”.
When a spatial index can be applied, the QgsSpatialIndex.nearestNeighbor function of the join layer index is used to find the nearest neighbour for each input feature.
Layer (row: input; column: join) | Point | Non-point | Non-point, index approx. |
---|---|---|---|
Point | Spatial index used | Spatial index used | Spatial index used (inexact) |
Non-point | Spatial index used (optional) | Spatial index used (optional) | NA |
Non-point, approximate | Spatial index used | Spatial index used | Spatial index used (inexact) |
If the input and join layers have different Coordinate Reference Systems (CRS), the input geometry is transformed to the join layer CRS before the join is performed.
The join will fail if transformation between the input layer CRS and the join layer CRS is not possible.
The join layer should have a projected CRS.
The current version is 1.2.1
except multi-geometry layers.
1.2.0: Support for indexes on non-point join layers.
Stopped using approximate join layer geometries.
1.0.0: Threading