3

enter image description hereI have a CSV layer of points which I have succesfully imported into QGIS. My assets are a bit like wireless access points and I cannot have any of the points on the same channel within 2km. I therefore want to be able to click on a point and it automatically draw a 2km circle around it, and then have the ability to click on 4 points at the same time to ensure the circles do not overlap, if it does then click off a point which will make the circle dissapear and I try another point.

So far I have tried adding a 'proposed channel' column in my CSV and reimporting the data every time I change a single point channel but this is taking forever... Does anybody have any better ideas?

enter image description here

1
  • 1
    You can also try Vector - Geoproccessing tools - Buffer – BERA Dec 23 '20 at 14:09
6

I don't know why you want to do it interactively. You can use QGIS expressions to visualize those points that have a nearest neighbour less than 2 km away and than decide in each case what to do. You can use differnt forms of visualization, I show here one that connects points nearer than 2km with a line.

The advantage to use geometry generator: when you move or delete points, the line immediately adapts to the new situation and the lines change accordingly. So you can observe the effects in realtime. When all lines disappeared, than you are sure that you don't have any points closer than 2 km.

Of course, you could also use a simple expression like buffer ($geometry, 2000) to draw a 2km circle around your points, but than you have to look manually for points within this distance.

The expression below first evaluates if there are any points nearer than 2km and only than draws a line. You could use this expression as well to generate a new field with the field calculator that calculates the distance to the nearest point, using just this part of the expression: distance ($geometry, collect_geometries (overlay_nearest (@layer, $geometry )))

But I advice to try this: Add an additional symbol layer to your point layer, set it to Geometry generator, Geometry type: line and paste this expression:

if ( 
    distance (
        $geometry, 
        collect_geometries (
            overlay_nearest (
                @layer, 
                $geometry 
            ) 
        ) 
    ) < 2000 , 
    make_line (
        $geometry , 
        overlay_nearest ( 
            @layer , 
            $geometry )
        ), 
    NULL
)

You can see from the measure tool on the bottom right (red box) how far is 2 km on my map canvas and you can see that points with a distance less than this are connected with a line:

enter image description here

18
  • 1
    Thankyou for this, looks great. Im a bit of a newbie to QGIS, however do I add a new symbol layer? Thanks. – David I Dec 23 '20 at 13:54
  • 1
    Click the green plus to add a symbol layer (see upper right part on the screenshot), than set symbol layer type to geometry generator – Babel Dec 23 '20 at 14:10
  • 1
    See documentation: docs.qgis.org/3.16/en/docs/training_manual/basic_map/… – Babel Dec 23 '20 at 14:13
  • this does not appear to have worked for me...i am getting dots inside my original points. I do not know how to attach a photo but I am not getting the lines like you are yet my formula and options look the same – David I Dec 23 '20 at 15:18
  • You can add a screeshot in your original question, just edit it and revise your question – Babel Dec 23 '20 at 15:27
4

You can also use Rule-based layer styling with the geometry generator:

Set a filter rule as: is_selected() and geometry generator: buffer($geometry, 2000, 5):

enter image description here

And an else rule with simple marker styling:

enter image description here

Then select points: enter image description here

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.