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?
What do you call the action of "describing events as they happen" like sports anchors do?
In Pandemic, why take the extra step of eradicating a disease after you've cured it?
Find all letter Combinations of a Phone Number
5 band resistor. Red, orange, black, gold and black. It doesn't fit in to normal rules
What class is best to play when a level behind the rest of the party?
ASCII Meme Arrow Generator
Who is "He that flies" in Lord of the Rings?
What is this wall covering type?
My mom's return ticket is 3 days after I-94 expires
Why do (or did, until very recently) aircraft transponders wait to be interrogated before broadcasting beacon signals?
Why is the distribution of dark matter in a Galaxy different from the distribution of normal matter?
Why does there seem to be an extreme lack of public trashcans in Taiwan?
Is it safe to dpkg --set-selections on a newer version of a distro?
How to Handle Many Times Series Simultaneously?
Mathematica 12 has gotten worse at solving simple equations?
How to generate list of *all* available commands and functions?
one-hot-encoding categorical data gives error
How to avoid typing 'git' at the begining of every Git command
What is the logic behind charging tax _in the form of money_ for owning property when the property does not produce money?
How to befriend someone who doesn't like to talk?
Print "N NE E SE S SW W NW"
Insert a smallest possible positive integer into an array of unique integers
In American Politics, why is the Justice Department under the President?
Placement of positioning lights on A320 winglets
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 8 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
8 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
8 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
8 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
8 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 8 hours ago
JosephJoseph
59.1k7103208
59.1k7103208
1
Oh! that did the trick :) thanks!
– caio villaca
8 hours ago
add a comment |
1
Oh! that did the trick :) thanks!
– caio villaca
8 hours ago
1
1
Oh! that did the trick :) thanks!
– caio villaca
8 hours ago
Oh! that did the trick :) thanks!
– caio villaca
8 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
8 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
8 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 8 hours ago
snaileatersnaileater
2,153614
2,153614
yep, I need it to read the values from the list...
– caio villaca
8 hours ago
add a comment |
yep, I need it to read the values from the list...
– caio villaca
8 hours ago
yep, I need it to read the values from the list...
– caio villaca
8 hours ago
yep, I need it to read the values from the list...
– caio villaca
8 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