Skip to content

a QGIS-plugin to calculate the closest points for one layer to another

License

Notifications You must be signed in to change notification settings

jagodki/Closest-Points

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Closest Points

A QGIS-plugin for extracting the closest points from one layer to another.

Goal of the project

QGIS does not have a simple function to get the closest points from one layer to another layer, although PyQGIS provides such a function. There are some workarounds for calculating the nearest points, but they are not very userfriendly. This plugin provides the missing function with familiar, QGIS-standard interfaces. The functions of the plugin are also available via the processing framework and the toolbox.

Usage

The plugin is available in the official plugin repository. After downloading and installing, it is located in the vector menu. It can be called from the toolbox and via the processing framework too. The plugin offers mutliple functions, which are described in the following paragraphs.

Find closest point for each feature

This algorithm iterates over all features of one layer and calculates the closest point for each feature to a second layer. Only one point per input feature will be calculated.

Find all closest points for each feature

This algorithm iterates over all features of an input layer and calculates the closest points from this features to each feature of a second layer. The count of the closest points will be the product of the feature counts of both layers.

Output

The output will be a point layer and will has four columns:

  1. id - a unique id field
  2. from_fid - the fid of the feature to calculate the nearest point from
  3. to_fid - the fid of the feature to calculate the nearest point to
  4. distance - the shortest euclidean distance between the both features referenced by the fields from_id and to_id

The fields from_id and to_id can be used to create a join to the input layers.

Remarks

The plugin calculates the euklidean distance, i.e. it is recommended to use metric coordinate systems.