3

I need to manually digitize elevation point maps. (using QGIS 3.24) Instead of the default QGIS method ( enter point + enter height), I would like to inverse the sequence: specify the height and then digitize all points with the height automatically set in the attribute table.

I suppose this should be possibly with a persistent form where I'd enter the desired value and subsequently activate the edit/add point function.

Is such a thing possible in QGIS?

4 Answers 4

4
  1. Layer Properties
  2. Attributes form
  3. Drag and drop designer. Drag your elevation field to Form layout
  4. Set a default value

All points you add will get the value. Digitize then change the default value when you need other values.

enter image description here

3
  • Thank Bera and Erik for your replies I tried the defaults value method ( and last entered values) It works, but it is not flowing enough - I'd need to modify that value regularly. I've been searching to get just this option as a "non-modal" form, but haven't found that yet. for clarity: I come from an arcgis/view background. Non-modal does not seem to be in Qgis vocabulary . By non-modal or modeless, I mean a form which does not impose focus, other parts of qgis can be used (as points digitizing)
    – glenndm
    Jun 27 at 20:14
  • The closest I've come: 1) set the default value to a project variable f.e. Def_Height 2) using the python console (which is non-modal), I modify the variable using command QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), 'Def_Height','91') 3) carry on adding points, going back to 2) when needed admitted it is crude, but workable in Qgis lingo, what would non-modal be? thanks again for your help
    – glenndm
    Jun 27 at 20:27
  • You could create a small python script/function to update for example all points without heights with some value. And call with setheight(150) after you've added a number of points. Or update selected points
    – BERA
    Jun 28 at 5:20
3

In the settings, in the submenu digitizing you may tell QGIS to reuse the last entered value for attributes.

enter image description here

1
  • Danke Erik please see my comment on Bera reply.
    – glenndm
    Jun 27 at 20:21
0

The solution I came to, based on the suggestion by Bera

  1. set an project variable f.e. Def_Height

  2. set the default value to that project variable in the layer properties

  3. using the python console (which is non-modal), I modify the variable to the desired value using command QgsExpressionContextUtils.setProjectVariable(QgsProject.instance(), 'Def_Height','91')

  4. carry on adding points, going back to 2) when needed

a further slight improvement: using autoit3, I made two scripts to increase and decrease the variable by 1 (-1)
those 2 scripts are linked to hotkeys on my keyboard
I can add points with the set value, hit a hotkey and continue with the next value up or down. without having to open properties or manually entering commands.

As stated, it is crude, but works.

best regards

0

turns out the non-modal/modeless form was easier than expected

With QTdesigner I made a crude form with a height textbox, +button, -button and modify button.

once all points digitized, I now select the points of a same height, click the modify button on the form and continue.

btw: digitizing points and heights simultaneously felt slower.

from qgis.PyQt import uic
frm = uic.loadUi("./tools/Hupdate.ui")
def cmd_bt_up():
    frm.tb_Hg.setPlainText(  str(int(frm.tb_Hg.toPlainText()) + 1))
    
def cmd_bt_down():
    frm.tb_Hg.setPlainText( str(int(frm.tb_Hg.toPlainText()) - 1))

def cmd_bt_set():
    layer = QgsProject.instance().mapLayersByName( 'points_pt' )[0]
    layer.startEditing()
    for feat in layer.selectedFeatures():
        feat["Heigth"] = frm.tb_Hg.toPlainText()
        layer.updateFeature(feat)    
        
    layer.commitChanges()        

    frm.bt_up.clicked.connect( cmd_bt_up)
    frm.bt_down.clicked.connect( cmd_bt_down)
    frm.bt_set.clicked.connect( cmd_bt_set)
    frm.show()

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.