Selecting by attribute using Python and a listselecting by attribute and specific value replaceSubquery a list in select layer by attribute management using pythonQGIS create selection scriptUsing SelectLayerByAttribute with list of values in ArcPy?Selecting first items of same attribute value using PyQGIS?Selection by attribute from listSelecting layer by attribute in Python Toolbox of ArcPy?Selecting layers in PyQGISSelecting and updating attribute values using Python console in QGIS?Writing where_clause to Select Layer By Attribute for Python Add-in?
Why do (or did, until very recently) aircraft transponders wait to be interrogated before broadcasting beacon signals?
Parsing text written the millitext font
Can a Warforged suffer from magical exhaustion?
If the pressure inside and outside a balloon balance, then why does air leave when it pops?
How to generate list of *all* available commands and functions?
Why do Bhargava-Skinner-Zhang consider the ordering by height?
Can I use 220 V outlets on a 15 ampere breaker and wire it up as 110 V?
In American Politics, why is the Justice Department under the President?
Who is "He that flies" in Lord of the Rings?
Is Jesus the last Prophet?
Why would a home insurer offer a discount based on credit score?
Placement of positioning lights on A320 winglets
How much web presence should I have?
Create a cube from identical 3D objects
Should I list a completely different profession in my technical resume?
Does it make sense to use a wavelet that is equal to a sine of one period?
How to Convert an Object into Array in magento 2
Course development: can I pay someone to make slides for the course?
Realistic, logical way for men with medieval-era weaponry to compete with much larger and physically stronger foes
Professor Roman loves to teach unorthodox Chemistry
How can you estimate a spike story?
Why is my power MOSFET heating up when on?
What does this line mean in Zelazny's "The Courts of Chaos"?
Are the guests in Westworld forbidden to tell the hosts that they are robots?
Selecting by attribute using Python and a list
selecting by attribute and specific value replaceSubquery a list in select layer by attribute management using pythonQGIS create selection scriptUsing SelectLayerByAttribute with list of values in ArcPy?Selecting first items of same attribute value using PyQGIS?Selection by attribute from listSelecting layer by attribute in Python Toolbox of ArcPy?Selecting layers in PyQGISSelecting and updating attribute values using Python console in QGIS?Writing where_clause to Select Layer By Attribute for Python Add-in?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have been using this script to select a feature using Python:
layer = iface.activeLayer()
layer.selectByExpression('"Declividad"= value', QgsVectorLayer.SetSelection)
selection = layer.selectedFeatures()
But now, I need to select the values for Declividad from a list.
For exemple: list = [10,11,12], so I want to select the values 10,11 and 12 for Declividad.
How could I do that?
qgis pyqgis select-by-attribute
add a comment |
I have been using this script to select a feature using Python:
layer = iface.activeLayer()
layer.selectByExpression('"Declividad"= value', QgsVectorLayer.SetSelection)
selection = layer.selectedFeatures()
But now, I need to select the values for Declividad from a list.
For exemple: list = [10,11,12], so I want to select the values 10,11 and 12 for Declividad.
How could I do that?
qgis pyqgis select-by-attribute
add a comment |
I have been using this script to select a feature using Python:
layer = iface.activeLayer()
layer.selectByExpression('"Declividad"= value', QgsVectorLayer.SetSelection)
selection = layer.selectedFeatures()
But now, I need to select the values for Declividad from a list.
For exemple: list = [10,11,12], so I want to select the values 10,11 and 12 for Declividad.
How could I do that?
qgis pyqgis select-by-attribute
I have been using this script to select a feature using Python:
layer = iface.activeLayer()
layer.selectByExpression('"Declividad"= value', QgsVectorLayer.SetSelection)
selection = layer.selectedFeatures()
But now, I need to select the values for Declividad from a list.
For exemple: list = [10,11,12], so I want to select the values 10,11 and 12 for Declividad.
How could I do that?
qgis pyqgis select-by-attribute
qgis pyqgis select-by-attribute
edited 9 hours ago
snaileater
2,153614
2,153614
asked 9 hours ago
caio villacacaio villaca
446
446
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You could juse use an expression like:
layer = iface.activeLayer()
my_list = [10, 11, 12]
values = ','.join(str(x) for x in my_list)
layer.selectByExpression('"Declividad" IN (' + values + ')', QgsVectorLayer.SetSelection)
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
add a comment |
You can try the IN operator :
layer.selectByExpression('"Declividad" IN ('10','11','12')', QgsVectorLayer.SetSelection)
Or do u need to dynamically reference the list name ?
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
add a comment |
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%2f325337%2fselecting-by-attribute-using-python-and-a-list%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could juse use an expression like:
layer = iface.activeLayer()
my_list = [10, 11, 12]
values = ','.join(str(x) for x in my_list)
layer.selectByExpression('"Declividad" IN (' + values + ')', QgsVectorLayer.SetSelection)
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
add a comment |
You could juse use an expression like:
layer = iface.activeLayer()
my_list = [10, 11, 12]
values = ','.join(str(x) for x in my_list)
layer.selectByExpression('"Declividad" IN (' + values + ')', QgsVectorLayer.SetSelection)
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
add a comment |
You could juse use an expression like:
layer = iface.activeLayer()
my_list = [10, 11, 12]
values = ','.join(str(x) for x in my_list)
layer.selectByExpression('"Declividad" IN (' + values + ')', QgsVectorLayer.SetSelection)
You could juse use an expression like:
layer = iface.activeLayer()
my_list = [10, 11, 12]
values = ','.join(str(x) for x in my_list)
layer.selectByExpression('"Declividad" IN (' + values + ')', QgsVectorLayer.SetSelection)
answered 9 hours ago
JosephJoseph
59.1k7103208
59.1k7103208
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
add a comment |
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
1
1
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
Oh! that did the trick :) thanks!
– caio villaca
9 hours ago
add a comment |
You can try the IN operator :
layer.selectByExpression('"Declividad" IN ('10','11','12')', QgsVectorLayer.SetSelection)
Or do u need to dynamically reference the list name ?
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
add a comment |
You can try the IN operator :
layer.selectByExpression('"Declividad" IN ('10','11','12')', QgsVectorLayer.SetSelection)
Or do u need to dynamically reference the list name ?
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
add a comment |
You can try the IN operator :
layer.selectByExpression('"Declividad" IN ('10','11','12')', QgsVectorLayer.SetSelection)
Or do u need to dynamically reference the list name ?
You can try the IN operator :
layer.selectByExpression('"Declividad" IN ('10','11','12')', QgsVectorLayer.SetSelection)
Or do u need to dynamically reference the list name ?
answered 9 hours ago
snaileatersnaileater
2,153614
2,153614
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
add a comment |
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
yep, I need it to read the values from the list...
– caio villaca
9 hours ago
add a comment |
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%2f325337%2fselecting-by-attribute-using-python-and-a-list%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