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 each 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

  • it looks like your "point" layer isn't made up of points, where did it come from
    – Ian Turton
    Jun 27, 2017 at 12:08
  • Got the points from lines through the Q-Chainage Tool
    – Lena
    Jun 27, 2017 at 12:14
  • Think we'd need your data, or some of it, or more information about it, to diagnose this. The function works for me. Maybe one of your features has a null geometry...
    – Spacedman
    Jun 27, 2017 at 12:52
  • Please, do not forget about "What should I do when someone answers my question?"
    – Taras
    Nov 21, 2021 at 17:00

4 Answers 4


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

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

  • I posted a picture in the main-post: The function doesn't work, but I have no idea what caused the error ...
    – Lena
    Jun 27, 2017 at 11:55
  • Hi, I have just run this tool in QGIS 3.2, and it works but the fields with the Id sources (origin and destin points) always keeps in "0", so It's not useful at all :(
    – Digd
    Aug 16, 2018 at 12:25

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().


Then your updated Attribute table will look like:


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


  • I think this is the cartesian distance (shortest line) more than the ellipsoidal distance ? Jul 8, 2022 at 1:25

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.

  • 1
    Since we keep getting flags on this answer, can you please confirm that this is indeed the answer to your question?
    – Aaron
    Nov 11, 2020 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.