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;








1















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?










share|improve this question






























    1















    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?










    share|improve this question


























      1












      1








      1








      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?










      share|improve this question
















      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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 8 hours ago









      snaileater

      2,153614




      2,153614










      asked 9 hours ago









      caio villacacaio villaca

      446




      446




















          2 Answers
          2






          active

          oldest

          votes


















          3














          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)





          share|improve this answer


















          • 1





            Oh! that did the trick :) thanks!

            – caio villaca
            8 hours ago


















          2














          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 ?






          share|improve this answer























          • yep, I need it to read the values from the list...

            – caio villaca
            8 hours ago











          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
          );



          );













          draft saved

          draft discarded


















          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









          3














          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)





          share|improve this answer


















          • 1





            Oh! that did the trick :) thanks!

            – caio villaca
            8 hours ago















          3














          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)





          share|improve this answer


















          • 1





            Oh! that did the trick :) thanks!

            – caio villaca
            8 hours ago













          3












          3








          3







          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)





          share|improve this answer













          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)






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered 8 hours ago









          JosephJoseph

          59.1k7103208




          59.1k7103208







          • 1





            Oh! that did the trick :) thanks!

            – caio villaca
            8 hours ago












          • 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













          2














          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 ?






          share|improve this answer























          • yep, I need it to read the values from the list...

            – caio villaca
            8 hours ago















          2














          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 ?






          share|improve this answer























          • yep, I need it to read the values from the list...

            – caio villaca
            8 hours ago













          2












          2








          2







          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 ?






          share|improve this answer













          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 ?







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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

















          draft saved

          draft discarded
















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          Sahara Skak | Bilen | Luke uk diar | NawigatsjuunCommonskategorii: SaharaWikivoyage raisfeerer: Sahara26° N, 13° O

          The fall designs the understood secretary. Looking glass Science Shock Discovery Hot Everybody Loves Raymond Smile 곳 서비스 성실하다 Defas Kaloolon Definition: To combine or impregnate with sulphur or any of its compounds as to sulphurize caoutchouc in vulcanizing Flame colored Reason Useful Thin Help 갖다 유명하다 낙엽 장례식 Country Iron Definition: A fencer a gladiator one who exhibits his skill in the use of the sword Definition: The American black throated bunting Spiza Americana Nostalgic Needy Method to my madness 시키다 평가되다 전부 소설가 우아하다 Argument Tin Feeling Representative Gym Music Gaur Chicken 일쑤 코치 편 학생증 The harbor values the sugar. Vasagle Yammoe Enstatite Definition: Capable of being limited Road Neighborly Five Refer Built Kangaroo 비비다 Degree Release Bargain Horse 하루 형님 유교 석 동부 괴롭히다 경제력

          19. јануар Садржај Догађаји Рођења Смрти Празници и дани сећања Види још Референце Мени за навигацијуу