Clustering points and summing up attributes per cluster in QGIS





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







7















We want to find out the ideal location for sheds and the required dimensions of each shed. As input, we have a point layer with locations (each representing one arable field) and the estimated yield per point (per arable field).



What we now try to do is first to create four clusters for these fields. This should serve as an approximation of the ideal location for a new shed. We've done this by simply using the "point cluster" option in the "symbology" section and adjusting the distance until only four cluster points remained. These cluster points were then saved as new point shapefile.



How do we determine what points are actually clustered in each of the cluster points?



With this information, we can then sum up the estimated yields for all the single points per cluster. This would allow us to calculate whether the shed has to be designed for 10 tons or 100 tons of grain.










share|improve this question































    7















    We want to find out the ideal location for sheds and the required dimensions of each shed. As input, we have a point layer with locations (each representing one arable field) and the estimated yield per point (per arable field).



    What we now try to do is first to create four clusters for these fields. This should serve as an approximation of the ideal location for a new shed. We've done this by simply using the "point cluster" option in the "symbology" section and adjusting the distance until only four cluster points remained. These cluster points were then saved as new point shapefile.



    How do we determine what points are actually clustered in each of the cluster points?



    With this information, we can then sum up the estimated yields for all the single points per cluster. This would allow us to calculate whether the shed has to be designed for 10 tons or 100 tons of grain.










    share|improve this question



























      7












      7








      7


      1






      We want to find out the ideal location for sheds and the required dimensions of each shed. As input, we have a point layer with locations (each representing one arable field) and the estimated yield per point (per arable field).



      What we now try to do is first to create four clusters for these fields. This should serve as an approximation of the ideal location for a new shed. We've done this by simply using the "point cluster" option in the "symbology" section and adjusting the distance until only four cluster points remained. These cluster points were then saved as new point shapefile.



      How do we determine what points are actually clustered in each of the cluster points?



      With this information, we can then sum up the estimated yields for all the single points per cluster. This would allow us to calculate whether the shed has to be designed for 10 tons or 100 tons of grain.










      share|improve this question
















      We want to find out the ideal location for sheds and the required dimensions of each shed. As input, we have a point layer with locations (each representing one arable field) and the estimated yield per point (per arable field).



      What we now try to do is first to create four clusters for these fields. This should serve as an approximation of the ideal location for a new shed. We've done this by simply using the "point cluster" option in the "symbology" section and adjusting the distance until only four cluster points remained. These cluster points were then saved as new point shapefile.



      How do we determine what points are actually clustered in each of the cluster points?



      With this information, we can then sum up the estimated yields for all the single points per cluster. This would allow us to calculate whether the shed has to be designed for 10 tons or 100 tons of grain.







      qgis clustering connectivity-analysis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 30 at 0:39









      PolyGeo

      53.9k1782246




      53.9k1782246










      asked Mar 29 at 7:20









      cbrcbr

      454




      454






















          1 Answer
          1






          active

          oldest

          votes


















          5














          I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group).



          Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an attribute field CLUSTER_ID (values= 0, 1, 2, 3).



          enter image description here



          Then an expression like SUM("yield", "CLUSTER_ID") in the Field Calculator will return the total yield for each cluster. (E.G. the Sum_per_Cluster in the below example).



          enter image description here





          [Update]



          To obtain center point per the group (cluster), please try Mean coordinate(s) geoalgorithm in Processing Toolbox > Vector analysis.



          Mean coordinates dialog window will show an option Unique ID field. Select CLUSTER_ID field.






          share|improve this answer


























          • Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

            – cbr
            Mar 29 at 14:16













          • Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

            – cbr
            Mar 29 at 14:23













          • @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

            – Kazuhito
            Mar 29 at 21:47











          • @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

            – Kazuhito
            Mar 29 at 22:03













          • Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

            – cbr
            Mar 30 at 7:33












          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%2f317107%2fclustering-points-and-summing-up-attributes-per-cluster-in-qgis%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









          5














          I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group).



          Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an attribute field CLUSTER_ID (values= 0, 1, 2, 3).



          enter image description here



          Then an expression like SUM("yield", "CLUSTER_ID") in the Field Calculator will return the total yield for each cluster. (E.G. the Sum_per_Cluster in the below example).



          enter image description here





          [Update]



          To obtain center point per the group (cluster), please try Mean coordinate(s) geoalgorithm in Processing Toolbox > Vector analysis.



          Mean coordinates dialog window will show an option Unique ID field. Select CLUSTER_ID field.






          share|improve this answer


























          • Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

            – cbr
            Mar 29 at 14:16













          • Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

            – cbr
            Mar 29 at 14:23













          • @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

            – Kazuhito
            Mar 29 at 21:47











          • @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

            – Kazuhito
            Mar 29 at 22:03













          • Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

            – cbr
            Mar 30 at 7:33
















          5














          I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group).



          Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an attribute field CLUSTER_ID (values= 0, 1, 2, 3).



          enter image description here



          Then an expression like SUM("yield", "CLUSTER_ID") in the Field Calculator will return the total yield for each cluster. (E.G. the Sum_per_Cluster in the below example).



          enter image description here





          [Update]



          To obtain center point per the group (cluster), please try Mean coordinate(s) geoalgorithm in Processing Toolbox > Vector analysis.



          Mean coordinates dialog window will show an option Unique ID field. Select CLUSTER_ID field.






          share|improve this answer


























          • Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

            – cbr
            Mar 29 at 14:16













          • Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

            – cbr
            Mar 29 at 14:23













          • @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

            – Kazuhito
            Mar 29 at 21:47











          • @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

            – Kazuhito
            Mar 29 at 22:03













          • Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

            – cbr
            Mar 30 at 7:33














          5












          5








          5







          I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group).



          Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an attribute field CLUSTER_ID (values= 0, 1, 2, 3).



          enter image description here



          Then an expression like SUM("yield", "CLUSTER_ID") in the Field Calculator will return the total yield for each cluster. (E.G. the Sum_per_Cluster in the below example).



          enter image description here





          [Update]



          To obtain center point per the group (cluster), please try Mean coordinate(s) geoalgorithm in Processing Toolbox > Vector analysis.



          Mean coordinates dialog window will show an option Unique ID field. Select CLUSTER_ID field.






          share|improve this answer















          I would try K-means clustering algorithm in the QGIS Processing Toolbox (under Vector analysis group).



          Just by setting the Number of clusters as 4, it will produce a new Clusters layer with an attribute field CLUSTER_ID (values= 0, 1, 2, 3).



          enter image description here



          Then an expression like SUM("yield", "CLUSTER_ID") in the Field Calculator will return the total yield for each cluster. (E.G. the Sum_per_Cluster in the below example).



          enter image description here





          [Update]



          To obtain center point per the group (cluster), please try Mean coordinate(s) geoalgorithm in Processing Toolbox > Vector analysis.



          Mean coordinates dialog window will show an option Unique ID field. Select CLUSTER_ID field.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 30 at 21:36

























          answered Mar 29 at 8:43









          KazuhitoKazuhito

          16.4k41884




          16.4k41884













          • Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

            – cbr
            Mar 29 at 14:16













          • Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

            – cbr
            Mar 29 at 14:23













          • @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

            – Kazuhito
            Mar 29 at 21:47











          • @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

            – Kazuhito
            Mar 29 at 22:03













          • Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

            – cbr
            Mar 30 at 7:33



















          • Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

            – cbr
            Mar 29 at 14:16













          • Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

            – cbr
            Mar 29 at 14:23













          • @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

            – Kazuhito
            Mar 29 at 21:47











          • @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

            – Kazuhito
            Mar 29 at 22:03













          • Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

            – cbr
            Mar 30 at 7:33

















          Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

          – cbr
          Mar 29 at 14:16







          Thank you very much for the quick and helpful reply! How did you create the center points of the clusters? When I use the method I described in my initial post (using "Symbology" and "Cluster"), I get center points completely off the actual cluster center (see [ibb.co/VmkhS0x]). This may stem from the different calculation methods. What approach did you use in your example? Furthermore, I get a lot of "NULL" results when I do the K-means clustering (see [ibb.co/VNdQ7bS]). Do you have a solution for this issue? Thank you very much!

          – cbr
          Mar 29 at 14:16















          Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

          – cbr
          Mar 29 at 14:23







          Since I only get error pages when trying to access the uploaded images but cannot edit the comment anymore (>5 min), here other links: Cluster center -> imgur.com/a/fs3R1K1 ; NULL -> imgur.com/a/Cv7IuCr

          – cbr
          Mar 29 at 14:23















          @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

          – Kazuhito
          Mar 29 at 21:47





          @cbr To create center point for each cluster, please use Centroids geoalgorithm. I will update my post. As to the center points (red circles) in my example, they were Point cluster symbology just for comparison.

          – Kazuhito
          Mar 29 at 21:47













          @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

          – Kazuhito
          Mar 29 at 22:03







          @cbr Your upperleft (north western) cluster in the provided image has only two locations in that cluster, which does not seem right. (You would not build shed just for those two). I am not sure what happened with locations with NULL outputs; they may be outliers. Perhaps I would check their locations visually, and manually assign most appropriate cluster id.

          – Kazuhito
          Mar 29 at 22:03















          Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

          – cbr
          Mar 30 at 7:33





          Thanks very much for your reply! The centroids algorithm only returns the same location for each of the selected points (so the output is a layer with the same amount of points as the input layer). I assume that the center point for each point was calculated but not one single point for the whole cluster... Is there another intermediate step necessary I made have missed?

          – cbr
          Mar 30 at 7:33


















          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%2f317107%2fclustering-points-and-summing-up-attributes-per-cluster-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