[GRASS-user] vectors: how to find the gravitation centre of point
data ?
Moritz Lennert
mlennert at club.worldonline.be
Fri Dec 5 07:40:08 EST 2008
On 05/12/08 12:27, Peter Löwe wrote:
> [...]
>>> is there an easy way to derive the centre of a cloud of points ?
>>>
>>> I am aware that the set of vector points ("cloud of points") could be
>>> used to stake out a polygon/boundary and use v.centroid etc etc to
>>> derive in turn its' centroid, but I am hoping for an easier solution
>>> .. ?
>>>
>>> This issue stems from working with v.to.db: currently it is not
>>> possible to upload xy coordinates for "multiploygons" into a
>>> database, i.e: Within a vector layer, there might be several
>>> boundaries which all share the same category value. If the
>>> "gravitational centre/ super-centroid" for these boundaries could be
>>> (conveniently) calculated, the v.to.db issue could be taken care of.
>>
>> Why not use v.dissolve on these polygons and then get the centroids of
>> the result ?
>
> This option fails if the polygons don't have common borders. An example for this would be multiple polygons describing spatial exclaves of a territory/county/soil type, etc.
>
>> Another (very wild) guess: what about the mean of the coordinates of the
>> individual polygons' centroids ?
>
> That would be great if it could be automated.
Using a "real" DB-backend, it should be as easy as (assuming that when
you say boundaries, you mean areas, each of which has a centroid):
- v.to.db type=centroid option=coor
- SELECT cat, avg(X), avg(Y) from TABLE group by cat
If you have boundaries with categories, but no centroids, I imagine that
v.centroids + v.distance with upload=cat should do the trick to transfer
boundary cats to their centroids.
Moritz
More information about the grass-user
mailing list