[GRASS-dev] [GRASS GIS] #1654: v.extract: allow direct transformation of centroids to polygons

#1654: v.extract: allow direct transformation of centroids to polygons
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
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

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1654&gt;
GRASS GIS <http://grass.osgeo.org>

#1654: v.extract: allow direct transformation of centroids to points
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1654#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#1654: v.extract: allow direct transformation of centroids to points
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1654#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#1654: v.extract: allow direct transformation of centroids to points
-------------------------+--------------------------------------------------
Reporter: mlennert | Owner: grass-dev@…
     Type: enhancement | Status: new
Priority: normal | Milestone: 7.0.0
Component: Default | Version: unspecified
Keywords: | Platform: Unspecified
      Cpu: Unspecified |
-------------------------+--------------------------------------------------

Comment(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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1654#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#1654: v.extract: allow direct transformation of centroids to points
--------------------------+-------------------------------------------------
  Reporter: mlennert | Owner: grass-dev@…
      Type: enhancement | Status: closed
  Priority: normal | Milestone: 7.0.0
Component: Default | Version: unspecified
Resolution: wontfix | Keywords:
  Platform: Unspecified | Cpu: Unspecified
--------------------------+-------------------------------------------------
Changes (by mlennert):

  * status: new => closed
  * resolution: => wontfix

Comment:

Replying to [comment:3 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

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/1654#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>