11 votes
Accepted

Why is SQL Server 2019's STDistance Very Slightly Different Than The Vincenty Formula? (Same Up To ~0.0001km)

SQL Server's STDistance function does not compute geodesic distances. Its algorithm essentially generates straight lines in 3D, densifies them and maps them on the ellipsoid in a manner described more ...
FSimardGIS's user avatar
  • 3,786
11 votes

How do I interpret the results from the distance matrix?

You can use a heatmap renderer for your point layers (in the symbology, change from Single Symbol to Heatmap) to see how/if the patterns overlap. That's probably the easiest and fastest way to get a ...
Babel's user avatar
  • 63.1k
8 votes

Calculating distance between points of same layer using QGIS?

There are a couple of versions of this tool. If you use the one from the Processing Toolbox, it will contain distances within the origin points. Instead, use the Distance Matrix tool from the menubar: ...
Joseph's user avatar
  • 75k
8 votes
Accepted

Distance between two points - by ID in QGIS

Assuming your data structure is like below id, start_x, start_y, end_x, end_y This is straighforward in QGIS if you have data in a projected CRS. You can add your text file as a vector layer, and ...
spatialthoughts's user avatar
7 votes

What algorithm does QGIS use to calculate Nearest Neighbor Index?

You can check the source code for the Nearest Neighbour Analysis tool from GitHub. More specifically, the following lines of code which shows how the different parameters are calculated: do = float(...
Joseph's user avatar
  • 75k
6 votes
Accepted

Solving ‘Null geometry…’ error during distance matrix operation?

The file signif.txt has missing lon/lats for some records which result in null geometries when you add as a delimited text layer or convert to other format. Either delete them or filter (Right click ...
user2856's user avatar
  • 63.9k
6 votes
Accepted

No output in PyQGIS standalone script running Distance Matrix?

I have found and fixed the final errors. I tried changing how each algorthim parameter got its value. By changing the code below: inputfield = QgsProperty.fromField("InputPointID") targetfield = ...
alanajones's user avatar
6 votes
Accepted

Aggregating features values based on distance in QGIS

Let's assume there is a polygon layer called 'grid_test' with nine features in it, see image below. Step 1. Apply the "Centroids" (This step you already did) Step 2. By means of the "...
Taras's user avatar
  • 29.9k
6 votes

Calculating distance between consecutive points in same point layer in QGIS

You can use the following script in QGIS Python Editor. It returns the distance in meter for geographic crs. Note: ID field should be integer/numeric. If it is string, you get wrong order like: 1, 10, ...
Kadir Şahbaz's user avatar
5 votes
Accepted

distance matrix with a linear feature

I did have the same the same research question as you. I wanted to calculate the distance from archaeological sites to rivers. I did have access to a hydrological layer by INEGI. I did have rivers as ...
Gerardo Jimenez's user avatar
5 votes
Accepted

Distance Matrix PostGis

As others have said, I don't think this pivot can be done in PostgreSQL however the distance calculation certainly can be. First you need a simple table of the distances, because ST_Distance and all ...
Evan Carroll's user avatar
  • 6,971
5 votes
Accepted

Calculate distance matrix in km units

The unit of EPSG:27700, OSGB 1936 / British National Grid is meter, which means the distances you got are in meter. You need to divide by 1000 and you will get the distance in km.
ahmadhanb's user avatar
  • 40.3k
5 votes

Excluding point from Nearest neighbor search once it's been matched using R?

Here's a sequential algorithm that used FNN::get.knnx to get the nearest neighbour of each point in list1 in succession, dropping the nearest neighbour from list2 and keeping track of its index in the ...
Spacedman's user avatar
  • 61.5k
5 votes
Accepted

Calculate distances from points to multiple country borders in QGIS

You can achieve this using a virtual layer. The idea is to read the points, join them to the polygon layer to get the polygons where the points are located, then join again these polygons to the ...
JGH's user avatar
  • 39.7k
5 votes

Measuring minimum distances for closest features between two polygon layers in QGIS

On the orange polygon, use this expression to get an array of the $id of the green polygons within 10000 m distance: overlay_nearest ('green',$id, max_distance:=10000,limit:=-1) Replace green with ...
Babel's user avatar
  • 63.1k
5 votes

Calculating distance between consecutive points in same point layer in QGIS

I'm sure there's some less complicated way, but you can use pyqgis like this: lyr = QgsProject.instance().mapLayersByName('Vertices')[0] #Change Vertices to the name of your layer orderfield = '...
BERA's user avatar
  • 67.1k
4 votes
Accepted

QGIS: Distance units in CRS layer: WGS 84

Edit: I assume you are using EPSG:4326 as CRS since it is the most common WGS84 CRS. If it is not the case, you should precise which CRS you are using based on the EPSG code. Distances in a WGS84 (...
ArMoraer's user avatar
  • 5,569
4 votes
Accepted

QGIS: calculate distance between points

Have you tried the Points2One plugin mentioned in this post. You should be able to create lines, grouped by the point IDs. Once you have the line layer you could calculate a line length to get the ...
Andrew Jeffrey's user avatar
4 votes
Accepted

OSM table(Matrix) Api returning distance 0 for small routes

You need to swap the coordinates, Lat in place of long and long in place of lat as below: http://router.project-osrm.org/table/v1/drive/72.5024,22.9755;72.5647,23.0143;72.4796,23.0483?sources=0
Shiko's user avatar
  • 2,873
4 votes
Accepted

QGIS Distance Matrix Output

Depending on what exactly you want to do with the data once you know the start, end and distance between the points you may find that the "Linear (N*k x 3) distance matrix" output matrix type is ...
Phil G's user avatar
  • 713
4 votes

Calculating shortest distance between points within polygon using QGIS?

I have no idea on how to do it with shapefile with existing tools, but an algorithm that iteratively adds vertices of the polygon to the line that joins the two points (until the new line is fully ...
radouxju's user avatar
  • 49.3k
4 votes
Accepted

Distance Matrix with 2 point shapefiles and one street network

You can use the plugin QNEAT3 which is available for QGIS3. It offers multiple processing algorithms that produce origin-destination matrices (OD-Matrix) as line layer, table or csv file. It also ...
root676's user avatar
  • 2,375
4 votes
Accepted

dist2Line - Error in dist2Line(...) could not find the function "dist2Line"

In your code none of used packages have this function. That is why R can't find it. Error in dist2Line(points,line,distfun=distHaversine) : could not find the function "dist2Line" Probably you want ...
Oto Kaláb's user avatar
  • 6,765
4 votes
Accepted

Points Layer to Distance Matrix QGIS 3.6 - Noosa

The error gives also an answer: convert to single points first. This can be done with the algorithm 'Multipart to singleparts'. You can link both algorithms in the graphical modeller: processing > ...
PieterB's user avatar
  • 5,237
4 votes
Accepted

Travel Distance Calculation in QGIS

The question of "what's the best method" is entirely subjective and specific to your situation. The best way to answer this question, in my opinion, is for you to research the different ...
csk's user avatar
  • 24.3k
4 votes
Accepted

Calculating distance from centroid points to multiple polygon edges with SpatialLite

Works for me with test data that I created according to your description. I made a successful test both with spatialite_gui program and with QGIS 3.4.4 (see the image). Is the name of your geometry ...
user30184's user avatar
  • 61.9k
4 votes
Accepted

What is the proper way to calculate distance in km from degrees

Convert your points to UTM first using Rgdal, for example: dir <- 'C:/your/path' setwd(dir)#set working directory pointfile <- 'points.csv' data <- read.csv(pointfile)#read in data library(...
Kartograaf's user avatar
  • 2,844
4 votes

Calculating distance between consecutive points in same point layer in QGIS

I am not sure if this is the best / fastest way, but I think it should work for you: length( make_line( $geometry, geometry( get_feature_by_id('*NAME/ID_of_your_layer*',...
Nunkuat's user avatar
  • 465
3 votes
Accepted

PostGIS - Calculate of the average distance between points for a delimited area

Sounds like you are looking for ST_DWithin(): SELECT * FROM points as r LEFT JOIN points as s ON ST_DWithin(s.geom, r.geom, 2); and this to get the average: SELECT r.id, s.id, AVG(...
kttii's user avatar
  • 3,580
3 votes

Need to get distance matrix for large set of points on-the-fly

Open Source Routing Machine is a project of Open Street Map (OSM) also provides distance matrix results although you may find that a 1k x 1k matrix is pushing it. You can build and install locally or ...
Peter Scott's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible