# Getting longest distance between multiple points and creating multiple polygons from lines using QGIS?

I am still a beginner with GIS.

I can't find an easy way to get a maximum distance from multiple points.

I have a layer of up to 100 points (without a unique ID - maybe that is part of the problem? but I could easily add that) and I want to get the length of maximum distance between any two of them.

I tried plenty of line-points plugins, but nothing seems to work, I also tried to make a minimum convex polygon (basically convex hull of all the points) and get a diagonal of that but failed in all tries again.

How do I do this without using a programming language?

I am using QGIS 2.18.5

• Vector, Analysis Tools, Distance Matrix will calculate the Distance between each Point. You can Sort the results to find the max distance. Apr 17, 2017 at 19:56

You will need an id of each record. Then a Spatialite self cross join SQL query of a virtual layer will give the distance between every point.

In the Field Calculator:

Make a new integer column called id and update it with row_number:

Make a virtual layer:

Write the SQL:

``````select st_distance(t1.geometry, t2.geometry) as dist, t1.id as id1, t2.id as id2
from testpnt t1
cross join testpnt t2
order by 1 desc
``````

Like:

Result:

Note:

This solution returns duplicated records (distance) for every two points, since id 1 is compared to id 2 and id 2 is also compared to id 1 in a cross join.

Update: The original table looks like this:

• If I have to use the SQL, may you please show me a printscreen of your point layer so I can write it correctly? Sorry, as I said, don't know the language, so I can't modify it to make it work. Apr 17, 2017 at 20:38
• The only column you need in your point table is an id column. You can have all the columns you like, but one of them must be an id column. Updated the answer. Apr 18, 2017 at 7:34