Skip to main content
deleted 1 character in body
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

youYou are not farefar away, just some lines of code:

lyr = iface.activeLayer()
fts = lyr.getFeatures()
lyr.startEditing()
for f in fts:
    f['myfield']='mystring'
    lyr.updateFeature(f)
lyr.commitChanges() #ends the editing session and commit all changes

for some good examples see:
https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/
or
https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/

you are not fare away, just some lines of code:

lyr = iface.activeLayer()
fts = lyr.getFeatures()
lyr.startEditing()
for f in fts:
    f['myfield']='mystring'
    lyr.updateFeature(f)
lyr.commitChanges() #ends the editing session and commit all changes

for some good examples see:
https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/
or
https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/

You are not far away, just some lines of code:

lyr = iface.activeLayer()
fts = lyr.getFeatures()
lyr.startEditing()
for f in fts:
    f['myfield']='mystring'
    lyr.updateFeature(f)
lyr.commitChanges() #ends the editing session and commit all changes

for some good examples see:
https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/
or
https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/

Source Link
eurojam
  • 11.9k
  • 1
  • 14
  • 29

you are not fare away, just some lines of code:

lyr = iface.activeLayer()
fts = lyr.getFeatures()
lyr.startEditing()
for f in fts:
    f['myfield']='mystring'
    lyr.updateFeature(f)
lyr.commitChanges() #ends the editing session and commit all changes

for some good examples see:
https://anitagraser.com/pyqgis-101-introduction-to-qgis-python-programming-for-non-programmers/pyqgis101-creating-editing-a-new-vector-layer/
or
https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/