Opened 8 years ago

Closed 8 years ago

#1654 closed enhancement (wontfix)

v.extract: allow direct transformation of centroids to points

Reported by: mlennert Owned by: grass-dev@…
Priority: normal Milestone: 7.0.0
Component: Default Version: unspecified
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

A recurrent task is to extract centroids from polygons and to use them as points in further analysis. Currently, one has to do this in two steps:

v.extract in=polygonmap out=centroidmap type=centroid
v.type in=centroidmap out=pointmap type=centroid,point

As this is IMHO such a basic operation, it would be great if v.extract could directly create a point layer. This could be implemented in different ways (in my order of preference):

1) If map contains polygons, but no points and type=point is given, then extract the centroids as points, if type=centroid extract as centroids.

2) If type=centroid is given, extract as points by default, but allow to extract as centroids by use of a flag

3) If type=centroid is given, extract as centroids by default, but allow to extract as points by use of a flag

A problem obviously might occur if a map contains a mix of polygons and points...

Moritz

Change History (4)

comment:1 Changed 8 years ago by mlennert

Summary: v.extract: allow direct transformation of centroids to polygonsv.extract: allow direct transformation of centroids to points

comment:2 Changed 8 years ago by hamish

"do one thing well" and don't duplicate or blur functionality.

to perform multiple actions at once write a wrapper script.

thanks, Hamish

comment:3 Changed 8 years ago by hamish

sorry if that came out harsh, I was in a hurry and meant to be brief, but not curt.

option 3 is the most acceptable to me, but even then I'd open access to it with a lot of caution. Remember that the absolute position of a centroid is just somewhere within the area, it is not guaranteed to be in the middle, so users must be very careful treating them as points with absolute x,y,z meaning. e.g. "C", "O", "L" shaped areas; areas created by v.buffer or v.overlay may have centroids may have their centroids right near an outside edge; etc.

I'm not sure how you are using it, but fwiw see also the add on module v.points.cog: "v.points.cog is a shell script which will create a new point at the center of gravity of each cluster of input points or centroids, grouped by attribute. Among other things this is useful for labeling swarms of points."

regards, Hamish

comment:4 in reply to:  3 Changed 8 years ago by mlennert

Resolution: wontfix
Status: newclosed

Replying to hamish:

sorry if that came out harsh, I was in a hurry and meant to be brief, but not curt.

No offense taken at all. KISS is a principle that can also be applied to trac tickets :-).

I see your point, and am inclined to agree with it. At the same time, I have the feeling that when extracting centroids out of polygons being able to treat them as points from there on would be the expected behaviour without having to go through v.type. But I guess a wrapper script would be ok.

option 3 is the most acceptable to me, but even then I'd open access to it with a lot of caution. Remember that the absolute position of a centroid is just somewhere within the area, it is not guaranteed to be in the middle, so users must be very careful treating them as points with absolute x,y,z meaning. e.g. "C", "O", "L" shaped areas; areas created by v.buffer or v.overlay may have centroids may have their centroids right near an outside edge; etc.

I'm aware of the issues with GRASS centroids, but for many applications this kind of precision is not necessary.

I'm not sure how you are using it,

Here the use case was a colleague trying to use v.what.rast, with polygons as starting vector features. Centroid precision was enough for his needs. But other use cases exist.

In GRASS one can often treat centroids as points, but that's not the case for all of them, so in this particular use case, I'll rather file a ticket for v.what.rast to allow use of centroids.

Closing this for now.

Moritz

Note: See TracTickets for help on using tickets.