2

I have a PostGIS table with more than one geometry column (here: 2), like

enter image description here

One geometry is allways set, the other(s) may or may not be set:

enter image description here

In QGIS these come as two distinct layers, in my case one point and one polygon layer:

enter image description here

I am interested in an efficient way to capture both (or better n) geometries at once, preferably in one attribute form.

So far, my process seems little clumsy.

  1. Toggle on edit state of both QGIS layers
  2. Digitize objects in (in this case) the point layer
  3. Save layer edits in order to make Postgres create the id's
  4. Find out the id of the object for which I would like to digitize the other geometry, e.g. with Identify Features Tool
  5. Identify object in the second layer by the id (Select features by value...)
  6. Define the geometry with Add part digitizing tool (or edit an existing geometry)
  7. Save layer edits

Q: Does anyone know an easier and faster way to capture multiple geometry columns in QGIS?

(What I'm dreaming of is a dedicated widget type for capturing geometries in the attribute form, but that would be another topic...)

1 Answer 1

0

I have solved this so far with a python action (on feature scope) on my point layer that incorporates the above steps 3 to 5. The solution targets a specific layer name and assumes the id column called "id". The action (layer properties > actions) is defined like this:

enter image description here

The python code is short and basically self-explanatory:

from qgis.core import QgsProject
from qgis.utils import iface

id = [%id%]
# target layer name should be unique
target_lyr = QgsProject.instance().mapLayersByName('Abbruch Fläche')[0]
iface.setActiveLayer(target_lyr)
target_lyr.selectByExpression(f'"id"={id}')
target_lyr.startEditing()
iface.actionAddPart().trigger()

With activated Show in Attributes Table and re-ordering columns I have ...

enter image description here

... in addition to the Identify features-right-click-contextmenu:

enter image description here

One could think of a more generic solution that finds layers with the same data source (in order not to hard-code the layer name) and asks for which connected geometry to add and detects the id column (column with unique values) automatically.

1
  • Also if the two geometry are related (like if the point geometry is the centroid of the multipolygon geometry for exemple) you may try to generate the second geometry programatically
    – J.R
    Commented Feb 3, 2022 at 16:12

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.