Prioritising polygons in QGIS

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












3















I just created a layer in which I hand drew a lot of polygons.



Now I want to fill out the Attribute table through commands since it will save me a bunch of time.



Therefore, I calculated the area of each polygon using $area/10000 to have the size in ha.



I want to prioritize each area



  • above 10 ha as Prio 1

  • each below 1 ha as Prio 3

  • each in between as Prio 2

Does anyone have a smart solution to the problem?



My closest approach is: IF ("Size ha" > 10, 1, 2)



That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.










share|improve this question
























  • Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

    – Erik
    Feb 26 at 10:25















3















I just created a layer in which I hand drew a lot of polygons.



Now I want to fill out the Attribute table through commands since it will save me a bunch of time.



Therefore, I calculated the area of each polygon using $area/10000 to have the size in ha.



I want to prioritize each area



  • above 10 ha as Prio 1

  • each below 1 ha as Prio 3

  • each in between as Prio 2

Does anyone have a smart solution to the problem?



My closest approach is: IF ("Size ha" > 10, 1, 2)



That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.










share|improve this question
























  • Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

    – Erik
    Feb 26 at 10:25













3












3








3








I just created a layer in which I hand drew a lot of polygons.



Now I want to fill out the Attribute table through commands since it will save me a bunch of time.



Therefore, I calculated the area of each polygon using $area/10000 to have the size in ha.



I want to prioritize each area



  • above 10 ha as Prio 1

  • each below 1 ha as Prio 3

  • each in between as Prio 2

Does anyone have a smart solution to the problem?



My closest approach is: IF ("Size ha" > 10, 1, 2)



That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.










share|improve this question
















I just created a layer in which I hand drew a lot of polygons.



Now I want to fill out the Attribute table through commands since it will save me a bunch of time.



Therefore, I calculated the area of each polygon using $area/10000 to have the size in ha.



I want to prioritize each area



  • above 10 ha as Prio 1

  • each below 1 ha as Prio 3

  • each in between as Prio 2

Does anyone have a smart solution to the problem?



My closest approach is: IF ("Size ha" > 10, 1, 2)



That however still leaves me with having to distinguish the areas of Prio 2 to Prio 3 manually.







qgis polygon attribute-table command-line






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 6:48







Philip Gatzlaff

















asked Feb 26 at 10:18









Philip GatzlaffPhilip Gatzlaff

243




243












  • Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

    – Erik
    Feb 26 at 10:25

















  • Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

    – Erik
    Feb 26 at 10:25
















Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

– Erik
Feb 26 at 10:25





Just a general annotation: The expamples given on the different tools in the field calculator are quite useful to picture, how the tools work.

– Erik
Feb 26 at 10:25










3 Answers
3






active

oldest

votes


















5














This should work



if($area/10000 > 10,1,if($area/10000 < 1,3,2))


Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.






share|improve this answer






























    5














    CASE
    WHEN "Size ha" >= 10 THEN 'Prio 1'
    WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
    WHEN "Size ha" <= 1 THEN 'Prio 3'
    END


    Or as was provided by @Erik, the upper formula can be rewritten as



    if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))



    References:



    • Expressions | Conditionals

    • Elseif Conditional Statement in QGIS Field Calculator





    share|improve this answer

























    • Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

      – Philip Gatzlaff
      Feb 26 at 10:23












    • Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

      – Erik
      Feb 26 at 10:23






    • 1





      @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

      – Erik
      Feb 26 at 10:32






    • 1





      @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

      – Taras
      Feb 26 at 10:35






    • 1





      Just create a new column and fill it with CASE formula.

      – Taras
      Feb 26 at 10:39


















    0














    CASE



    WHEN "Size ha" =>10 THEN 'Prio 1' for the area above 10 ha



    WHEN "Size ha" <10 AND "Size" >1 THEN 'Prio 2' for the area between 10 ha to 1 ha



    WHEN "Size ha" <1 THEN 'Prio 3' for the area below 1 ha



    END



    Use the code to update the priority field.






    share|improve this answer
























      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%2f313607%2fprioritising-polygons-in-qgis%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      5














      This should work



      if($area/10000 > 10,1,if($area/10000 < 1,3,2))


      Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.






      share|improve this answer



























        5














        This should work



        if($area/10000 > 10,1,if($area/10000 < 1,3,2))


        Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.






        share|improve this answer

























          5












          5








          5







          This should work



          if($area/10000 > 10,1,if($area/10000 < 1,3,2))


          Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.






          share|improve this answer













          This should work



          if($area/10000 > 10,1,if($area/10000 < 1,3,2))


          Just a capsuled if-condition, first checking for areas greater 10 ha, then checking for those smaller than 1 ha, then giving everything else prio 2.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 26 at 10:22









          ErikErik

          3,323322




          3,323322























              5














              CASE
              WHEN "Size ha" >= 10 THEN 'Prio 1'
              WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
              WHEN "Size ha" <= 1 THEN 'Prio 3'
              END


              Or as was provided by @Erik, the upper formula can be rewritten as



              if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))



              References:



              • Expressions | Conditionals

              • Elseif Conditional Statement in QGIS Field Calculator





              share|improve this answer

























              • Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

                – Philip Gatzlaff
                Feb 26 at 10:23












              • Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

                – Erik
                Feb 26 at 10:23






              • 1





                @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

                – Erik
                Feb 26 at 10:32






              • 1





                @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

                – Taras
                Feb 26 at 10:35






              • 1





                Just create a new column and fill it with CASE formula.

                – Taras
                Feb 26 at 10:39















              5














              CASE
              WHEN "Size ha" >= 10 THEN 'Prio 1'
              WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
              WHEN "Size ha" <= 1 THEN 'Prio 3'
              END


              Or as was provided by @Erik, the upper formula can be rewritten as



              if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))



              References:



              • Expressions | Conditionals

              • Elseif Conditional Statement in QGIS Field Calculator





              share|improve this answer

























              • Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

                – Philip Gatzlaff
                Feb 26 at 10:23












              • Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

                – Erik
                Feb 26 at 10:23






              • 1





                @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

                – Erik
                Feb 26 at 10:32






              • 1





                @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

                – Taras
                Feb 26 at 10:35






              • 1





                Just create a new column and fill it with CASE formula.

                – Taras
                Feb 26 at 10:39













              5












              5








              5







              CASE
              WHEN "Size ha" >= 10 THEN 'Prio 1'
              WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
              WHEN "Size ha" <= 1 THEN 'Prio 3'
              END


              Or as was provided by @Erik, the upper formula can be rewritten as



              if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))



              References:



              • Expressions | Conditionals

              • Elseif Conditional Statement in QGIS Field Calculator





              share|improve this answer















              CASE
              WHEN "Size ha" >= 10 THEN 'Prio 1'
              WHEN "Size ha" > 1 AND "Size ha" < 10 THEN 'Prio 2'
              WHEN "Size ha" <= 1 THEN 'Prio 3'
              END


              Or as was provided by @Erik, the upper formula can be rewritten as



              if("Size ha" >= 10, 'Prio 1', if("Size ha" <= 1, 'Prio 3', 'Prio 2'))



              References:



              • Expressions | Conditionals

              • Elseif Conditional Statement in QGIS Field Calculator






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Mar 7 at 7:17

























              answered Feb 26 at 10:22









              TarasTaras

              2,2992727




              2,2992727












              • Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

                – Philip Gatzlaff
                Feb 26 at 10:23












              • Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

                – Erik
                Feb 26 at 10:23






              • 1





                @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

                – Erik
                Feb 26 at 10:32






              • 1





                @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

                – Taras
                Feb 26 at 10:35






              • 1





                Just create a new column and fill it with CASE formula.

                – Taras
                Feb 26 at 10:39

















              • Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

                – Philip Gatzlaff
                Feb 26 at 10:23












              • Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

                – Erik
                Feb 26 at 10:23






              • 1





                @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

                – Erik
                Feb 26 at 10:32






              • 1





                @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

                – Taras
                Feb 26 at 10:35






              • 1





                Just create a new column and fill it with CASE formula.

                – Taras
                Feb 26 at 10:39
















              Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

              – Philip Gatzlaff
              Feb 26 at 10:23






              Ah, thanks. I tried using WHEN clauses, but somehow didnt end up at a fitting result. My command looked different though. I will try it out!

              – Philip Gatzlaff
              Feb 26 at 10:23














              Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

              – Erik
              Feb 26 at 10:23





              Another possbile solution, though I do not like doublechecks on conditions, they tend to be a bit complicated in my experience.

              – Erik
              Feb 26 at 10:23




              1




              1





              @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

              – Erik
              Feb 26 at 10:32





              @Taras that is my own judgement, I usually mess up conditions when having to check upper and lower boundaries ;-)

              – Erik
              Feb 26 at 10:32




              1




              1





              @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

              – Taras
              Feb 26 at 10:35





              @Erik, I think I will happen to me as well. However, when I have for instance 20 conditions I will be lost within a number of parenthesis in If-condition :-)

              – Taras
              Feb 26 at 10:35




              1




              1





              Just create a new column and fill it with CASE formula.

              – Taras
              Feb 26 at 10:39





              Just create a new column and fill it with CASE formula.

              – Taras
              Feb 26 at 10:39











              0














              CASE



              WHEN "Size ha" =>10 THEN 'Prio 1' for the area above 10 ha



              WHEN "Size ha" <10 AND "Size" >1 THEN 'Prio 2' for the area between 10 ha to 1 ha



              WHEN "Size ha" <1 THEN 'Prio 3' for the area below 1 ha



              END



              Use the code to update the priority field.






              share|improve this answer





























                0














                CASE



                WHEN "Size ha" =>10 THEN 'Prio 1' for the area above 10 ha



                WHEN "Size ha" <10 AND "Size" >1 THEN 'Prio 2' for the area between 10 ha to 1 ha



                WHEN "Size ha" <1 THEN 'Prio 3' for the area below 1 ha



                END



                Use the code to update the priority field.






                share|improve this answer



























                  0












                  0








                  0







                  CASE



                  WHEN "Size ha" =>10 THEN 'Prio 1' for the area above 10 ha



                  WHEN "Size ha" <10 AND "Size" >1 THEN 'Prio 2' for the area between 10 ha to 1 ha



                  WHEN "Size ha" <1 THEN 'Prio 3' for the area below 1 ha



                  END



                  Use the code to update the priority field.






                  share|improve this answer















                  CASE



                  WHEN "Size ha" =>10 THEN 'Prio 1' for the area above 10 ha



                  WHEN "Size ha" <10 AND "Size" >1 THEN 'Prio 2' for the area between 10 ha to 1 ha



                  WHEN "Size ha" <1 THEN 'Prio 3' for the area below 1 ha



                  END



                  Use the code to update the priority field.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 19 at 9:08

























                  answered Mar 19 at 9:00









                  Alvin KomenAlvin Komen

                  11




                  11



























                      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%2f313607%2fprioritising-polygons-in-qgis%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

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay