0

We have software that returns '5143m from PointA on PathB' and I need to know where that would be without using the measuring tool and snapping to manually trace the line. I am not looking to measure distances between points on a line nor find the distance from points to a line. Is there a plugin I can use or a native feature?


I need to figure the physical location of a point on a line (Point X, Line A) given the point at the start of the line (Point A) and a distance along the line. I.e., if I am given '4000m from Point A on Path B', then manually tracing Path B for 4000 meters from Point A should give me the location of Point X; whatever solution we find here should return the same result, saving me the tedium and time (I have quite a few of these to do).


I've done some more searching via linked questions, and solving this problem in ArcGIS would involve Linear Referencing and Interpolation. Is there something similar for QGIS?


The line I need to be traced is not straight; it is a polyline with vertices, turns, etc.

  • 1
    How is "point A" defined? Is it always the start of the line? – ndawson Oct 28 '16 at 23:24
  • Yes, Point A is always the start of the line. – Metalgearmaycry Oct 31 '16 at 11:56
  • Is this correct: you have two layers, one with lines, one with points (containing a line id + distance instead of geometry)? And do you only need to visualize or do you need a new layer? – Matthias Kuhn Oct 31 '16 at 14:16
  • I have just a line layer. I am given an arbitrary distance along that line from its starting point, and I need to visualize where on the line that distance ends. (That being said, putting that distance on a new layer would be useful.) – Metalgearmaycry Oct 31 '16 at 14:19
  • Have a look at the LRS plugin, in this answer I posted a brief description of its functionalities. In particular, you need to use the 'Locate' tab. – Germán Carrillo Oct 31 '16 at 14:56
2

In QGIS 2.18 was introduced a new feature that does the job you seek. The function is line_interpolate_point (geometry, distance), to be used in calcolatatore QGIS fields.

STEP 1: Create a new field 'wkt_field' (Text 255) and populate it with function: geom_to_wkt( line_interpolate_point ($ geometry, distance value));

STEP 2: export the layer as a CSV;

STEP 3: Load the new file with 'add layer delimited text' and select WKT

0

Find your coordinate reference system (CRS) by double-clicking a layer and looking at the "General" tab.

Then click the "Identify Features" button

(identify features)

and select a point in the view. A panel "Identify Results" should open, and if you expand the feature arrows in the "Identify Results" window, you can see the "clicked coordinate X" and "clicked coordinate Y" values. These will be relative to the CRS you are using (described at the beginning of this answer).

  • I tried this, but it isn't what I need. I need to figure the physical location of a point on a line (Point X, Line A) given the point at the start of the line (Point A) and a distance along the line. I.e., if I am given '4000m from Point A on Path B', then manually tracing Path B for 4000 meters from Point A should give me the location of Point X; whatever solution we find here should return the same result, saving me the tedium and time. – Metalgearmaycry Oct 31 '16 at 13:45
0

I don't use QGIS so I'm not sure what functions you have available to use for this, but from a purely mathematical sense and assuming you are using a cartesian coordinate system, you should be able to calculate the point fairly easily. Let's assume you have a line defined as running between Point A and Point B.

First, calculate the difference for each axis of the line between points A and B dX = Ax - Bx and dY = Ay - By

Second, we need to know how long the line is, we can use Pythagoras's theorem for that d = √(dx² + dy²)

Then we need to calculate the decimal percentage of the total length of the line that your distance makes up. pct = (myDist / d)

Finally, multiply dX and dY by the decimal percentage and then add them to the coordinates of the starting point (Ax, Ay). Px = dX * pct + Ax and Py = dY * pct + Ay

So, your point's coordinates are (Px, Py).

EDIT

In the case of a polyline you will need to calculate dX, dY and pct for each section of the line (note that pct should equal 1 for each section apart from the last one where you only travel along part of the section). Then, the final calculation of Px and Py should look like this:

Px = Ax + (dX₁ * pct₁) + (dX₂ * pct₂) + (dX₃ * pct₃) ...

Py = Ay + (dY₁ * pct₁) + (dY₂ * pct₂) + (dY₃ * pct₃) ...

...

Hopefully someone can expand on this with a workflow for QGIS or perhaps offer up some tools to do the work for you, but that should get you the coordinates you're after.

  • I guess I should have clarified that the line is not straight (i.e., a polyline with vertices); how would this work for one of those? – Metalgearmaycry Oct 31 '16 at 14:49
  • I've now included how this might work for a polyline in the answer above. I'm guessing this will probably require some python code to automate if you're doing more than a few lines. – T_Bacon Oct 31 '16 at 16:14
0

Apologies if this isn't what you're after but if you're just planning on marking these distances, how about a styling solution.

My example image is a 30m line. I've added an marker line and selected to mark only the first vertex. I then offset that by a certain distance (15m) and made sure to use the map units. If you have many lines that need the same distance, then I think this would be your easiest method, but if there is several different lengths you need to find then you can always use the data defined override.

point along line using the marker line style and offset

0

If you have a WKT (LINESTRING) of a single line this webtool basing on open layers 3 can help to get a cooridnate from start point:

https://maegger.github.io/point_along_line_at_certain_distance.html

I am the author of this tool...

0

Here's how to do this in the Python console or scripting - using the interpolate method:

# Select the source - in this case the selected layer
layer = iface.activeLayer()

# Iterating through the features
for f in layer.getFeatures():

    # Get the geometry and interpolate the position at a distance (500)
    xy = f.geometry().interpolate(500)
    print(xy)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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