QGIS extract average attribute value from layer based on vectorin a single vector layer I have a three of...

How do I deal with being jealous of my own players?

Plagiarism of code by other PhD student

Why can't we make a perpetual motion machine by using a magnet to pull up a piece of metal, then letting it fall back down?

Is divide-by-zero a security vulnerability?

Where is the fallacy here?

In iTunes 12 on macOS, how can I reset the skip count of a song?

What is better: yes / no radio, or simple checkbox?

The need of reserving one's ability in job interviews

Make me a metasequence

A right or the right?

Is there a math equivalent to the conditional ternary operator?

Why is it "take a leak?"

Is there a frame of reference in which I was born before I was conceived?

How to kill a localhost:8080

Are small insurances worth it

What could trigger powerful quakes on icy world?

How to substitute values from a list into a function?

For the ranger's Natural Explorer feature, which favored terrain are caves and dungeons classified under?

Toast materialize

How can I handle a player who pre-plans arguments about my rulings on RAW?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

How do you say "powers of ten"?

Are there any other Chaos-worshipping races?

Get length of the longest sequence of numbers with the same sign



QGIS extract average attribute value from layer based on vector


in a single vector layer I have a three of polygons with different field values (e.g1,2,3). How Can I color each field value polygon differently?Add attribute from underlying polygon based on maximum shared areaDirections based on polygon centroid and average/median point of adjacent polygon's touching borderHow to split a single polygon with another polygon (from a different layer) with QgisCreating a heatmap from vector grid and point layer with QGISCreate a raster layer that represents the distance from each polygon cell to the closest point in a bufferHow to get the selected value in a value map with Function Editor in QGIS 3.0.2?One to many intersection of polygonsUpdate/change/commit an attribute/a field value “on the fly” in QGIS 3Update polygon layer with summarized areas from other polygon layer













1















Say I have one layer below with the blue, red, and yellow polygons in the image below. Each of these values has a different value for attribute A. I have a second layer, which denoted by the bold box in the figure below. I would like to find the average value of attribute A within the area spanned by the bold layer. In the example case it should return an average value of 2 since. How would I do this type of calculation in QGIS 3?



enter image description here










share|improve this question



























    1















    Say I have one layer below with the blue, red, and yellow polygons in the image below. Each of these values has a different value for attribute A. I have a second layer, which denoted by the bold box in the figure below. I would like to find the average value of attribute A within the area spanned by the bold layer. In the example case it should return an average value of 2 since. How would I do this type of calculation in QGIS 3?



    enter image description here










    share|improve this question

























      1












      1








      1








      Say I have one layer below with the blue, red, and yellow polygons in the image below. Each of these values has a different value for attribute A. I have a second layer, which denoted by the bold box in the figure below. I would like to find the average value of attribute A within the area spanned by the bold layer. In the example case it should return an average value of 2 since. How would I do this type of calculation in QGIS 3?



      enter image description here










      share|improve this question














      Say I have one layer below with the blue, red, and yellow polygons in the image below. Each of these values has a different value for attribute A. I have a second layer, which denoted by the bold box in the figure below. I would like to find the average value of attribute A within the area spanned by the bold layer. In the example case it should return an average value of 2 since. How would I do this type of calculation in QGIS 3?



      enter image description here







      qgis qgis-3






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Feb 5 at 21:32









      JimJim

      61




      61






















          1 Answer
          1






          active

          oldest

          votes


















          0














          You are looking for the Weighted Arithmetic Mean calculation.



          There are many ways to do it and all depend on the form and conditions of the input data.



          But in short, all seek to perform the following calculation: Add the product of each value by the area occupied, and divide by the total area.



          For the proposal of just three polygons, we can see the manual way of doing it.



          My layer "polygons_a" has three fields: "id_a", "area_a" and "value_a".

          My layer "polygon_b" has two fields: "id_b" and "area_b".



          layers



          Make the intersection between "polygon_b" and "polygons_a" layers, keeping the "id_b" fields for the input layer, and the "id_a" and "value_a" fields for the overlay layer.



          intersection



          The output is a new "Intersection" layer. Populate a new field with the area of each intersection feature. I am working with a projected CRS and calculating the planimetric areas with the expression: area($geometry). I named that field: "area_int".



          area_int



          Now, you can calculate the weighted average value for the "polygon_b", in that layer, populating a new field with the folowing expression:



          (
          attribute( get_feature( 'Intersection', 'id_a', 1), 'value_a')
          *
          attribute( get_feature( 'Intersection', 'id_a', 1), 'area_int')
          +
          attribute( get_feature( 'Intersection', 'id_a', 2), 'value_a')
          *
          attribute( get_feature( 'Intersection', 'id_a', 2), 'area_int')
          +
          attribute( get_feature( 'Intersection', 'id_a', 3), 'value_a')
          *
          attribute( get_feature( 'Intersection', 'id_a', 3), 'area_int')
          ) / "area_b"


          The expression is just taking the values and areas of the "Intersection" layer, multiplying them and adding the products, to divide the result by the area of the "polygon_b" feature.



          weighted average





          share























            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%2f311156%2fqgis-extract-average-attribute-value-from-layer-based-on-vector%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You are looking for the Weighted Arithmetic Mean calculation.



            There are many ways to do it and all depend on the form and conditions of the input data.



            But in short, all seek to perform the following calculation: Add the product of each value by the area occupied, and divide by the total area.



            For the proposal of just three polygons, we can see the manual way of doing it.



            My layer "polygons_a" has three fields: "id_a", "area_a" and "value_a".

            My layer "polygon_b" has two fields: "id_b" and "area_b".



            layers



            Make the intersection between "polygon_b" and "polygons_a" layers, keeping the "id_b" fields for the input layer, and the "id_a" and "value_a" fields for the overlay layer.



            intersection



            The output is a new "Intersection" layer. Populate a new field with the area of each intersection feature. I am working with a projected CRS and calculating the planimetric areas with the expression: area($geometry). I named that field: "area_int".



            area_int



            Now, you can calculate the weighted average value for the "polygon_b", in that layer, populating a new field with the folowing expression:



            (
            attribute( get_feature( 'Intersection', 'id_a', 1), 'value_a')
            *
            attribute( get_feature( 'Intersection', 'id_a', 1), 'area_int')
            +
            attribute( get_feature( 'Intersection', 'id_a', 2), 'value_a')
            *
            attribute( get_feature( 'Intersection', 'id_a', 2), 'area_int')
            +
            attribute( get_feature( 'Intersection', 'id_a', 3), 'value_a')
            *
            attribute( get_feature( 'Intersection', 'id_a', 3), 'area_int')
            ) / "area_b"


            The expression is just taking the values and areas of the "Intersection" layer, multiplying them and adding the products, to divide the result by the area of the "polygon_b" feature.



            weighted average





            share




























              0














              You are looking for the Weighted Arithmetic Mean calculation.



              There are many ways to do it and all depend on the form and conditions of the input data.



              But in short, all seek to perform the following calculation: Add the product of each value by the area occupied, and divide by the total area.



              For the proposal of just three polygons, we can see the manual way of doing it.



              My layer "polygons_a" has three fields: "id_a", "area_a" and "value_a".

              My layer "polygon_b" has two fields: "id_b" and "area_b".



              layers



              Make the intersection between "polygon_b" and "polygons_a" layers, keeping the "id_b" fields for the input layer, and the "id_a" and "value_a" fields for the overlay layer.



              intersection



              The output is a new "Intersection" layer. Populate a new field with the area of each intersection feature. I am working with a projected CRS and calculating the planimetric areas with the expression: area($geometry). I named that field: "area_int".



              area_int



              Now, you can calculate the weighted average value for the "polygon_b", in that layer, populating a new field with the folowing expression:



              (
              attribute( get_feature( 'Intersection', 'id_a', 1), 'value_a')
              *
              attribute( get_feature( 'Intersection', 'id_a', 1), 'area_int')
              +
              attribute( get_feature( 'Intersection', 'id_a', 2), 'value_a')
              *
              attribute( get_feature( 'Intersection', 'id_a', 2), 'area_int')
              +
              attribute( get_feature( 'Intersection', 'id_a', 3), 'value_a')
              *
              attribute( get_feature( 'Intersection', 'id_a', 3), 'area_int')
              ) / "area_b"


              The expression is just taking the values and areas of the "Intersection" layer, multiplying them and adding the products, to divide the result by the area of the "polygon_b" feature.



              weighted average





              share


























                0












                0








                0







                You are looking for the Weighted Arithmetic Mean calculation.



                There are many ways to do it and all depend on the form and conditions of the input data.



                But in short, all seek to perform the following calculation: Add the product of each value by the area occupied, and divide by the total area.



                For the proposal of just three polygons, we can see the manual way of doing it.



                My layer "polygons_a" has three fields: "id_a", "area_a" and "value_a".

                My layer "polygon_b" has two fields: "id_b" and "area_b".



                layers



                Make the intersection between "polygon_b" and "polygons_a" layers, keeping the "id_b" fields for the input layer, and the "id_a" and "value_a" fields for the overlay layer.



                intersection



                The output is a new "Intersection" layer. Populate a new field with the area of each intersection feature. I am working with a projected CRS and calculating the planimetric areas with the expression: area($geometry). I named that field: "area_int".



                area_int



                Now, you can calculate the weighted average value for the "polygon_b", in that layer, populating a new field with the folowing expression:



                (
                attribute( get_feature( 'Intersection', 'id_a', 1), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 1), 'area_int')
                +
                attribute( get_feature( 'Intersection', 'id_a', 2), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 2), 'area_int')
                +
                attribute( get_feature( 'Intersection', 'id_a', 3), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 3), 'area_int')
                ) / "area_b"


                The expression is just taking the values and areas of the "Intersection" layer, multiplying them and adding the products, to divide the result by the area of the "polygon_b" feature.



                weighted average





                share













                You are looking for the Weighted Arithmetic Mean calculation.



                There are many ways to do it and all depend on the form and conditions of the input data.



                But in short, all seek to perform the following calculation: Add the product of each value by the area occupied, and divide by the total area.



                For the proposal of just three polygons, we can see the manual way of doing it.



                My layer "polygons_a" has three fields: "id_a", "area_a" and "value_a".

                My layer "polygon_b" has two fields: "id_b" and "area_b".



                layers



                Make the intersection between "polygon_b" and "polygons_a" layers, keeping the "id_b" fields for the input layer, and the "id_a" and "value_a" fields for the overlay layer.



                intersection



                The output is a new "Intersection" layer. Populate a new field with the area of each intersection feature. I am working with a projected CRS and calculating the planimetric areas with the expression: area($geometry). I named that field: "area_int".



                area_int



                Now, you can calculate the weighted average value for the "polygon_b", in that layer, populating a new field with the folowing expression:



                (
                attribute( get_feature( 'Intersection', 'id_a', 1), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 1), 'area_int')
                +
                attribute( get_feature( 'Intersection', 'id_a', 2), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 2), 'area_int')
                +
                attribute( get_feature( 'Intersection', 'id_a', 3), 'value_a')
                *
                attribute( get_feature( 'Intersection', 'id_a', 3), 'area_int')
                ) / "area_b"


                The expression is just taking the values and areas of the "Intersection" layer, multiplying them and adding the products, to divide the result by the area of the "polygon_b" feature.



                weighted average






                share











                share


                share










                answered 7 mins ago









                Gabriel De LucaGabriel De Luca

                3,003217




                3,003217






























                    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%2f311156%2fqgis-extract-average-attribute-value-from-layer-based-on-vector%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

                    Щит и меч (фильм) Содержание Названия серий | Сюжет |...

                    Венесуэла на летних Олимпийских играх 2000 Содержание Состав...

                    Meter-Bus Содержание Параметры шины | Стандартизация |...