I would like to be able to move two layers that look like you see below:
Basically, when I move the polygon object, to which the lines are snapped as a separate layer I want them to be intact at the end. I can't merge these layers and promote them to multipart because I need them separately. I just want to know the option, which will allow me to make the drag including these 2 layers (or more optionally).
Similar issues were potentially here:
- Snapping polygon layer to another layer automatically
- Selecting features within polygon from another layer using QGIS
but they didn't solve my problem.
Is it possible to do operation such as this in QGIS?
Best Answer
One option is to use an
endpoint
point layer, the existingpole
polygon layer and to compute a virtuallines
layer, that is updated each time the map is moved.The
endpoint
must have apoleID
attribute, that is populated of the polygon it should be connected to.The
pole
layer must have a uniquepoleID
attribute.The virtual layer can have any attribute from the
endpoint
or thepole
layer, in addition to create a line between the two geometries.When you touch the map (pan, move, refresh etc), the lines are automatically recomputed. You can use the virtual layer like any other layer, or you can export it to another format if you need to persist the data.
Go the the menu
layer / add layer / add-edit virtual layer
and enter the following query.after moving the pole polygon:
PS: this solution produces real lines that can be used for further analysis, in contrast with the excellent
geometry_generator
solution that produces lines for display only.