I have a layer of point locations distributed country-wide. I would like to create a new point layer that shows the mean or center of mass of the points, but grouped based on the value of a field, such as province or municipality. Thus we have the mean coordinates of the points within each province or municipality.
How do I do this in QGIS?
Best Answer
One can try the "Mean coordinate(s)" geoalgorithm.
Let's assume there is a point layer called 'points_test' with its attribute table, see image below
Fields:
"id"
: a unique identifier"Group"
: a grouping field for points (corresponds to your province or municipality). In case you do not have these values, please use additionally the "Join attributes by location""Weight"
: a field with weightsHow does this geoalgorithm work?
I. Using the geoalgorithm without checked fields
It will return just one dot (a yellow one).
II. Applying only the
'Unique ID field'
It will result in one point for each unique group, check the red dots
III. Setting both the
'Unique ID field'
and the'Weight field'
It will result in one point for each unique group based on the points' field with weights, see the green dots
One should always distinguish between:
Only in specific (and rare) cases, they are equal.
References: