4

I have a shapefile with >300 points that correspond to the points where vegetation survey plots were carried out 10m from the road on both sides. Plots have the dimensions 20mx50m. The attributes table has a row for each plot and a column that indicates whether the plot was made on the left or right side of the road. I need to place a polygon 20m measured perpendicular to the road of said dimensions, on either side of the GPS point (as shown in the image below)

enter image description here

I have a survey trail shapefile that I extracted indices from that has an angle column (which I think should be useful) which I hope to use to determine the perpendicular angle for the polygon placement. The geometries have been made to line up perfectly (point shapefile and line shapefile).

Points lie on the survey route, 20m perpendicular in both directions need to have survey plot polygons of 50mx20m (dark blue lines only cover river name)

I have searched a variety of things on StackExchange and Google, but this is quite a unique and complex geometry issue that I think has not been tackled before. I am aware that I can create a polygon for each point and then manually move it but I was hoping not to since in total there will be more than 600 polygons. I am on QGIS 3.4.4 Madeira, Windows 10.

EDIT

Each point (representing two vegetation plots, one either side) has a timestamp, so it is clear which direction is forward as it gets later. From this, we should be able to determine which side was right and which left to the surveyor. Polygons are to be parallel to the survey trail (line shapefile).

  • What do you mean saying on the left/right side of the road? Do you mean one direction roads? – Vadym Dec 31 '18 at 16:13
  • I mean in the direction of travel. For each plot (point) I have a datetime stamp which indicates the direction of travel. So as the time increases we can tell the surveyor is moving forward and from this we can ascertain left or right. Does that make it clearer? – Nebulloyd Dec 31 '18 at 16:24
  • I see. For solving this problem some python code can be implemented in form of the layer action that would generate the desired rectangles. – Vadym Dec 31 '18 at 16:34
  • 1
    Your example looks N-S aligned, but in general the polygons will be angled parallel with the road at the survey point, yes? – Spacedman Dec 31 '18 at 17:14
  • Yes, exactly. Orienting the diagram in a rough N-S way was probably unfortunate – Nebulloyd Jan 1 at 11:45
4

This will give you a rectangle of 20 x 50m at one side of the survey point, which is oriented to the next survey.

single_sided_buffer(
  offset_curve(
    make_line(
      project($geometry, -25, azimuth(
                               $geometry, 
                               geometry(
                                get_feature_by_id('your_layer', $id+1)))) 
      , project($geometry, 25, azimuth(
                              $geometry, 
                              geometry(
                               get_feature_by_id('your_layer', $id+1)))))
  , 10) 
, 20)

You can create two rectangles and combine them into one.

union(
 single_sided_buffer(
  offset_curve(
   make_line(project($geometry, -25, azimuth($geometry, geometry(get_feature_by_id('your_layer', $id+1)))), project($geometry, 25, azimuth($geometry, geometry(get_feature_by_id('your_layer', $id+1))))), 10), 20),
 single_sided_buffer(
  offset_curve(
   make_line(project($geometry, -25, azimuth($geometry, geometry(get_feature_by_id('your_layer', $id+1)))), project($geometry, 25, azimuth($geometry, geometry(get_feature_by_id('your_layer', $id+1))))), -10), -20))

Notes:

  • make_line() creates a 50m line from the survey point
  • offset_curve() shifts the line to the side by 10m.
  • single_sided_buffer() creates a buffer of 20m from the offset line.

enter image description here

  • Thank you, I have tried to run but I am receiving an invalid syntax error exec(open('C:/Users/NICHOL~1/AppData/Local/Temp/tmpphpalusf.py'.encode('utf-8')).read()) Traceback (most recent call last): File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\code.py", line 90, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "<string>", line 4 project($geometry, -25, azimuth( ^ SyntaxError: invalid syntax – Nebulloyd Jan 7 at 14:53
  • It appears to really dislike the $ symbols, is this something that is used in pyQGIS 3? Does it indicate column as in R? – Nebulloyd Jan 7 at 15:03
  • @Nebulloyd These are QGIS expressions. You can use either Geometry by expression (Processing - Vector geometry tools) or Geometry generator. – Kazuhito Jan 7 at 18:15

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.