Prioritising polygons in QGIS












1















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" > 5, 1, 2)



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










share|improve this question









New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • 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
    19 hours ago
















1















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" > 5, 1, 2)



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










share|improve this question









New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • 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
    19 hours ago














1












1








1








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" > 5, 1, 2)



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










share|improve this question









New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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" > 5, 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









New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 18 hours ago









nmtoken

7,95642766




7,95642766






New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 19 hours ago









Philip GatzlaffPhilip Gatzlaff

61




61




New contributor




Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Philip Gatzlaff is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 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
    19 hours ago



















  • 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
    19 hours ago

















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
19 hours ago





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
19 hours ago










2 Answers
2






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































    4














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


    Reference:




    • Expressions | Conditionals






    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
      19 hours ago













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

      – Erik
      19 hours ago






    • 1





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

      – Erik
      19 hours ago






    • 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
      19 hours ago






    • 1





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

      – Taras
      19 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
    });


    }
    });






    Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.










    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

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    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 19 hours ago









        ErikErik

        3,273322




        3,273322

























            4














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


            Reference:




            • Expressions | Conditionals






            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
              19 hours ago













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

              – Erik
              19 hours ago






            • 1





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

              – Erik
              19 hours ago






            • 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
              19 hours ago






            • 1





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

              – Taras
              19 hours ago
















            4














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


            Reference:




            • Expressions | Conditionals






            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
              19 hours ago













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

              – Erik
              19 hours ago






            • 1





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

              – Erik
              19 hours ago






            • 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
              19 hours ago






            • 1





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

              – Taras
              19 hours ago














            4












            4








            4







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


            Reference:




            • Expressions | Conditionals






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


            Reference:




            • Expressions | Conditionals







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 18 hours ago

























            answered 19 hours ago









            TarasTaras

            2,1672624




            2,1672624













            • 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
              19 hours ago













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

              – Erik
              19 hours ago






            • 1





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

              – Erik
              19 hours ago






            • 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
              19 hours ago






            • 1





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

              – Taras
              19 hours ago



















            • 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
              19 hours ago













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

              – Erik
              19 hours ago






            • 1





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

              – Erik
              19 hours ago






            • 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
              19 hours ago






            • 1





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

              – Taras
              19 hours ago

















            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
            19 hours ago







            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
            19 hours ago















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

            – Erik
            19 hours ago





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

            – Erik
            19 hours ago




            1




            1





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

            – Erik
            19 hours ago





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

            – Erik
            19 hours ago




            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
            19 hours ago





            @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
            19 hours ago




            1




            1





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

            – Taras
            19 hours ago





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

            – Taras
            19 hours ago










            Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.













            Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.












            Philip Gatzlaff is a new contributor. Be nice, and check out our Code of Conduct.
















            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

            "Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

            Alcedinidae

            RAC Tourist Trophy