Selecting an amount of features that together sum up to a certain value?

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
4
down vote

favorite












I am looking for a way in QGIS to randomly select features within my shapefile. The selected features together need to sum up to more or less 2000m2.
So, it is not selecting 10% of the features, but 10% of the sum of one attribute of the features (20 000 m2 in this case)










share|improve this question





























    up vote
    4
    down vote

    favorite












    I am looking for a way in QGIS to randomly select features within my shapefile. The selected features together need to sum up to more or less 2000m2.
    So, it is not selecting 10% of the features, but 10% of the sum of one attribute of the features (20 000 m2 in this case)










    share|improve this question

























      up vote
      4
      down vote

      favorite









      up vote
      4
      down vote

      favorite











      I am looking for a way in QGIS to randomly select features within my shapefile. The selected features together need to sum up to more or less 2000m2.
      So, it is not selecting 10% of the features, but 10% of the sum of one attribute of the features (20 000 m2 in this case)










      share|improve this question















      I am looking for a way in QGIS to randomly select features within my shapefile. The selected features together need to sum up to more or less 2000m2.
      So, it is not selecting 10% of the features, but 10% of the sum of one attribute of the features (20 000 m2 in this case)







      qgis area select






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 13 at 10:56









      Kadir

      3,6771025




      3,6771025










      asked Aug 13 at 9:50









      Jtv

      232




      232




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          I don't think ther's an out of the box solution for this. One option for you would be to use Python to create a script. If however, you aren't familiar with coding you can try the following...



          Create your area field using field calculator and if you haven't got one already create an id field with sequential numbers from 1 to the total number of features in the layer. Then export the layer to csv and open in excel.



          Order the table by the id column and create a new field calling 'running_total'. Assuming your area field is column c and row 1 are your headers, calculate the running total with the formula =SUM($C$2:$C2). If you're familiar with excel you'll notice that all the references are absolute except the last one, so Drag this formula to the bottom and you'll get the running total. This is better explained here. Note down the id where the running total is closest to 20000.



          Back in QGIS select by attribute all features who's ids are less than or equal to the id you noted earlier.






          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',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f292593%2fselecting-an-amount-of-features-that-together-sum-up-to-a-certain-value%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            I don't think ther's an out of the box solution for this. One option for you would be to use Python to create a script. If however, you aren't familiar with coding you can try the following...



            Create your area field using field calculator and if you haven't got one already create an id field with sequential numbers from 1 to the total number of features in the layer. Then export the layer to csv and open in excel.



            Order the table by the id column and create a new field calling 'running_total'. Assuming your area field is column c and row 1 are your headers, calculate the running total with the formula =SUM($C$2:$C2). If you're familiar with excel you'll notice that all the references are absolute except the last one, so Drag this formula to the bottom and you'll get the running total. This is better explained here. Note down the id where the running total is closest to 20000.



            Back in QGIS select by attribute all features who's ids are less than or equal to the id you noted earlier.






            share|improve this answer
























              up vote
              4
              down vote



              accepted










              I don't think ther's an out of the box solution for this. One option for you would be to use Python to create a script. If however, you aren't familiar with coding you can try the following...



              Create your area field using field calculator and if you haven't got one already create an id field with sequential numbers from 1 to the total number of features in the layer. Then export the layer to csv and open in excel.



              Order the table by the id column and create a new field calling 'running_total'. Assuming your area field is column c and row 1 are your headers, calculate the running total with the formula =SUM($C$2:$C2). If you're familiar with excel you'll notice that all the references are absolute except the last one, so Drag this formula to the bottom and you'll get the running total. This is better explained here. Note down the id where the running total is closest to 20000.



              Back in QGIS select by attribute all features who's ids are less than or equal to the id you noted earlier.






              share|improve this answer






















                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                I don't think ther's an out of the box solution for this. One option for you would be to use Python to create a script. If however, you aren't familiar with coding you can try the following...



                Create your area field using field calculator and if you haven't got one already create an id field with sequential numbers from 1 to the total number of features in the layer. Then export the layer to csv and open in excel.



                Order the table by the id column and create a new field calling 'running_total'. Assuming your area field is column c and row 1 are your headers, calculate the running total with the formula =SUM($C$2:$C2). If you're familiar with excel you'll notice that all the references are absolute except the last one, so Drag this formula to the bottom and you'll get the running total. This is better explained here. Note down the id where the running total is closest to 20000.



                Back in QGIS select by attribute all features who's ids are less than or equal to the id you noted earlier.






                share|improve this answer












                I don't think ther's an out of the box solution for this. One option for you would be to use Python to create a script. If however, you aren't familiar with coding you can try the following...



                Create your area field using field calculator and if you haven't got one already create an id field with sequential numbers from 1 to the total number of features in the layer. Then export the layer to csv and open in excel.



                Order the table by the id column and create a new field calling 'running_total'. Assuming your area field is column c and row 1 are your headers, calculate the running total with the formula =SUM($C$2:$C2). If you're familiar with excel you'll notice that all the references are absolute except the last one, so Drag this formula to the bottom and you'll get the running total. This is better explained here. Note down the id where the running total is closest to 20000.



                Back in QGIS select by attribute all features who's ids are less than or equal to the id you noted earlier.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Aug 13 at 10:41









                firefly-orange

                1,616118




                1,616118



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f292593%2fselecting-an-amount-of-features-that-together-sum-up-to-a-certain-value%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    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