2

I am digitising line-features based on WGS-84 point-coordinates from a PDF which cannot be copied from.

The final line layer should contain lines which each connect two points and have the following attributes:

  • Name of start point - name of end point
  • value in [ft]
  • value in [m]
  • remark (same for all features)
  • date of creation

Currently I have a csv-based point layer which simply contains the name and coordinates of each point.


Creating the point layer is no problem, but creating the lines is a bit of a hassle. Either I manually create a .csv containing all existing connections between points like the following table and run connect by lines:

enter image description here

Or I digitise the lines manually but fill in the values (except for the value in [ft]) automatically.


Personally I would prefer option 2, since option 1 involves more manual work and the process has to be repeated regularly (and I figure I could transfer the solution to other tasks), but I can't get the expression right which should fill in the name of the line. All other values are created flawlessly (though they are not taken from another layer based on geometry).

I added the WKT of each point to the point-layer. Currently I am running the following, which returns NULL, despite it seems to be correct to me:

attribute(get_feature('point-layer','geom',geom_to_wkt(start_point($geometry))),'Waypoint')||' - '||attribute(get_feature('point-layer','geom',geom_to_wkt(end_point($geometry))),'Waypoint')

Any ideas where I went wrong?

  • 1
    Are the numbers in "geom" attribute field the same as the number you expect from geom_to_wkt(), down to all decimal places? Rounding or precision issue of numbers by any chance? – Kazuhito Jun 12 at 9:18
  • They should be, since I snap my lines to the points. /edit: They are. – Erik Jun 12 at 9:38
3

You could try the aggregate function to get the value of WayPoint where the object in point-layer intersects the start_point (and end_point) of the digitised line. This might work better than trying to compare the WKTs:

aggregate(layer:='point-layer', aggregate:='max', expression:="WayPoint",
          filter:= intersects( $geometry, start_point(geometry(@parent)))) 
||' - '||  
aggregate(layer:='point-layer', aggregate:='max', expression:="WayPoint",
          filter:= intersects( $geometry, end_point(geometry(@parent))))

This only works in QGIS 3, the geometry(@parent) function wasn't available in QGIS 2.x

  • Works perfectly, thank you very much =) – Erik Jun 13 at 14:24
  • Works great - what does 'Max' do? – GeorgeC Jul 22 at 4:00
  • 1
    @GeorgeC 'Max' is just one of the aggregate functions - along with Min, Sum and others. You could for example get the Max RL of all the points within a polygon, or sum the lengths of all the sewer lines with a polygon. In our particular case the filter will only return the single point which intersects the start point - the expression would still give the same result if you changed max to min (i.e. aggregate := 'min' – M Bain Jul 22 at 4:30

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.