How do I select attribute and update values using Python console in QGIS.? The 2019 Stack...
Who coined the term "madman theory"?
Time travel alters history but people keep saying nothing's changed
Can we generate random numbers using irrational numbers like π and e?
How to type this arrow in math mode?
Did Section 31 appear in Star Trek: The Next Generation?
Are there incongruent pythagorean triangles with the same perimeter and same area?
Reference request: Oldest number theory books with (unsolved) exercises?
How to support a colleague who finds meetings extremely tiring?
FPGA - DIY Programming
For what reasons would an animal species NOT cross a *horizontal* land bridge?
Why do UK politicians seemingly ignore opinion polls on Brexit?
What is the closest word meaning "respect for time / mindful"
Why hard-Brexiteers don't insist on a hard border to prevent illegal immigration after Brexit?
Is a "Democratic" Oligarchy-Style System Possible?
Apparent duplicates between Haynes service instructions and MOT
Why isn't airport relocation done gradually?
Why was M87 targetted for the Event Horizon Telescope instead of Sagittarius A*?
Deal with toxic manager when you can't quit
If a Druid sees an animal’s corpse, can they Wild Shape into that animal?
How to save as into a customized destination on macOS?
How to check whether the reindex working or not in Magento?
One word riddle: Vowel in the middle
Pokemon Turn Based battle (Python)
Protecting Dualbooting Windows from dangerous code (like rm -rf)
How do I select attribute and update values using Python console in QGIS.?
The 2019 Stack Overflow Developer Survey Results Are In“Select by Attribute” in QGIS using python?qgis python: select on screen and change (pre-set) properties accordinglyUpdate query adding values from multi column case statement in QGISScripting the mapping of style columns attributes in QGIS?Feature Selection Using Custom Python Expression Functions in QGIS 2.18QGIS: SQL query within python console to sum a column based on values of other two columnsCannot calculate new values for an empty attribute using existing attributes in QGIS with pythonSelect features using an expression, QGISBlank values in attribute table don't work as null in QGIS?Python Scripting in QGIS to add features and select them?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
Am working with Landusefc and class columns(ref table).
What I want is :Select all water from class and give a value say "8" in the landusefc column for these selected features
table1
I have tried the following code, but doesnt seem to work.
from qgis.core import *
import processing
layer=processing.getObject('test1')
query= ' "class" = 'Water' '
selection = layer.getFeatures(QgsFeatureRequest().setFilterExpression(query))
layer.setSelectedFeatures([k.id() for k in selection])
#using change Attribute to change the value of the selected feature
layer.startEditing()
for feat in selection:
layer.changeAttributeValue(feat.id(), 5, 8)
layer.commitChanges()
qgis pyqgis
add a comment |
Am working with Landusefc and class columns(ref table).
What I want is :Select all water from class and give a value say "8" in the landusefc column for these selected features
table1
I have tried the following code, but doesnt seem to work.
from qgis.core import *
import processing
layer=processing.getObject('test1')
query= ' "class" = 'Water' '
selection = layer.getFeatures(QgsFeatureRequest().setFilterExpression(query))
layer.setSelectedFeatures([k.id() for k in selection])
#using change Attribute to change the value of the selected feature
layer.startEditing()
for feat in selection:
layer.changeAttributeValue(feat.id(), 5, 8)
layer.commitChanges()
qgis pyqgis
add a comment |
Am working with Landusefc and class columns(ref table).
What I want is :Select all water from class and give a value say "8" in the landusefc column for these selected features
table1
I have tried the following code, but doesnt seem to work.
from qgis.core import *
import processing
layer=processing.getObject('test1')
query= ' "class" = 'Water' '
selection = layer.getFeatures(QgsFeatureRequest().setFilterExpression(query))
layer.setSelectedFeatures([k.id() for k in selection])
#using change Attribute to change the value of the selected feature
layer.startEditing()
for feat in selection:
layer.changeAttributeValue(feat.id(), 5, 8)
layer.commitChanges()
qgis pyqgis
Am working with Landusefc and class columns(ref table).
What I want is :Select all water from class and give a value say "8" in the landusefc column for these selected features
table1
I have tried the following code, but doesnt seem to work.
from qgis.core import *
import processing
layer=processing.getObject('test1')
query= ' "class" = 'Water' '
selection = layer.getFeatures(QgsFeatureRequest().setFilterExpression(query))
layer.setSelectedFeatures([k.id() for k in selection])
#using change Attribute to change the value of the selected feature
layer.startEditing()
for feat in selection:
layer.changeAttributeValue(feat.id(), 5, 8)
layer.commitChanges()
qgis pyqgis
qgis pyqgis
asked 4 mins ago
ShellyShelly
6
6
add a comment |
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318447%2fhow-do-i-select-attribute-and-update-values-using-python-console-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f318447%2fhow-do-i-select-attribute-and-update-values-using-python-console-in-qgis%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown