TransWikia.com

Measuring distance between points using QGIS

Geographic Information Systems Asked on July 12, 2021

I have a layer with about 500 single points. Now I want to measure the distance between each of these points and one specified observation point.

I need the distance to show how far away from the observation point every of these points was located to build a table for detection probability.

I already tried lots of Plugins (Hub Distance, NNJoin, …), but simply can’t find a proper way to calculate what I need.

enter image description here

4 Answers

Put your observation point in a point layer and use "Distance Matrix" from the Vector... Analysis Tools menu.

Make sure there's a unique ID column in your layer of points. I've got one point in the "source" layer and eleven in the "targets" layer. The table output has the ID of each target point and the distance to the source point. You could join this to the target layer if you need it there. Change the output matrix type to NxT. Here's the dialog and the resulting output:

enter image description here

Answered by Spacedman on July 12, 2021

Another option from mentioned by @Spacedman is the following:

  • Connect target points with the source point (observation one)
  • Measure distances for created lines

This option could also help you to create some nice visualizations.

  1. Prepare your data by creating unique fields in both (target and source) layers. enter image description here
  2. Install plugin 'Connect Points'. It is an experimented one, so make sure you ticked 'Show also experimental plugins' on your Plugins menu. Plugin works with WGS 84 CRS only
  3. Go to Plugins > Connect Points > Settings and set appropriate options.enter image description here
  4. Run the Plugin. Here is the following result: enter image description here
  5. Resave it with appropriate metrical CRS and count length of these lines by updating the length column with the function $length.
  6. Results are the same as by using 'Distance matrix' plus you've got a vector layer.enter image description here

Answered by Mykola Kozyr on July 12, 2021

OK, thanks so far. I think i figured out my problem. I have doubled IDs in my table so its impossible to connect each point with the source point.

Answered by Lena on July 12, 2021

In the "Field Calculator" of your point layer use the following expression:

length(shortest_line($geometry, geometry(get_feature('end', 'id', '7'))))

where get_feature('end', 'od', '7') refers to a feature by its "id" from a point layer called 'end', otherwise you can use geom_from_wkt().

result_expression

Then your updated Attribute table will look like:

result_at

If new geometries have to be created, then try using the "Geometry by expression" geoalgorithm from the QGIS's Toolbox with the following expression:

shortest_line($geometry, geometry(get_feature('end', 'id', '7')))

and get the output

result_lines

Answered by Taras on July 12, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP