4

I have a uniform point layer generated by using the Regular Points process. My goal is to connect (draw a line to join) a certain number of points in this points layer in a snake pattern.

My current process in PyQGIS works well with horizontal lines, just following the point "ID"s as I go. It makes it easy to count how many points I've accessed and stop when the limit is reached. However, I am stumped about how I can do this vertically, as the IDs will be fully out of order. Is there a way to force a uniform point field to assign "ID"s vertically instead of from left to right?

Edit: Horizontal "Snake" pattern here; I would like to achieve the same effect vertically. The snaking line would stop at a given # of points reached; once reached, a new line would start. Repeat until all points are reached.

Horizontal traverse

Edit2: Vertical example. Hand-drawn so doesn't line up that well but hope it does the trick to explain the outcome I have in mind:

Vertical lines

4
  • 3
    Could you share an image showing what kind of result you expect? Jan 24, 2023 at 21:46
  • Can you also share an image showing an exampe of the vertical lines you want to get?
    – Babel
    Jan 25, 2023 at 21:23
  • Related: gis.stackexchange.com/questions/73978/…
    – Vince
    Jan 25, 2023 at 21:38
  • It isn't elegant but you could make a point grid with your regular points pattern, rotate it 90 degrees and then spatially select and save those points within your shape to a new layer. Then use your old snake pattern method.
    – John
    Jan 26, 2023 at 12:58

1 Answer 1

0
  1. Open FieldCalculator: Make new Field y (float) with $y.
  2. Install the QGIS-Plugin "Sort and Number".
  3. Open the Plugin. Select your desired layer. For "1st field" select "y". For "New Fieldname" use whatever you want e.g. "id". This tool can overwrite current id Values!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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