[GRASS-dev] Individual vector feature processing: v.clump?

Hi,

for a calculation I need to loop over all vector features in a map in
order to perform individually a computation. For that I cannot use the
category information since it may be used as 1:n link.

I wonder if a new v.clump command would make sense or the addition of
a new method in v.category to simplify this task?
Eventually I would implement the processing loop as a Python script.

Markus

On Wed, Dec 3, 2014 at 5:51 PM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

for a calculation I need to loop over all vector features in a map in
order to perform individually a computation. For that I cannot use the
category information since it may be used as 1:n link.

I wonder if a new v.clump command would make sense or the addition of
a new method in v.category to simplify this task?

Adding unique categories to a new layer for the features in question
with v.category (take care of the type option) does not work in this
case?

Markus M

Eventually I would implement the processing loop as a Python script.

Markus
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

On Wed, Dec 3, 2014 at 9:47 PM, Markus Metz
<markus.metz.giswork@gmail.com> wrote:

On Wed, Dec 3, 2014 at 5:51 PM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

for a calculation I need to loop over all vector features in a map in
order to perform individually a computation. For that I cannot use the
category information since it may be used as 1:n link.

I wonder if a new v.clump command would make sense or the addition of
a new method in v.category to simplify this task?

Adding unique categories to a new layer for the features in question
with v.category (take care of the type option) does not work in this
case?

Likely it does (I am asking on behalf on another person not subscribed here).
I wonder how to make it more obvious. And, if there is a best
practice example written in Python/PyGRASS?

Markus

On Thu, Dec 4, 2014 at 8:34 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Dec 3, 2014 at 9:47 PM, Markus Metz
<markus.metz.giswork@gmail.com> wrote:

On Wed, Dec 3, 2014 at 5:51 PM, Markus Neteler <neteler@osgeo.org> wrote:

Hi,

for a calculation I need to loop over all vector features in a map in
order to perform individually a computation. For that I cannot use the
category information since it may be used as 1:n link.

I wonder if a new v.clump command would make sense or the addition of
a new method in v.category to simplify this task?

Adding unique categories to a new layer for the features in question
with v.category (take care of the type option) does not work in this
case?

Likely it does (I am asking on behalf on another person not subscribed here).
I wonder how to make it more obvious. And, if there is a best
practice example written in Python/PyGRASS?

For Python, you can have a look at g.gui.rlisetup for an example about
how to cycle through all vector features of a given type.

Markus M

Hi Markus,

On Thu, Dec 4, 2014 at 8:34 AM, Markus Neteler <neteler@osgeo.org> wrote:

On Wed, Dec 3, 2014 at 9:47 PM, Markus Metz

Adding unique categories to a new layer for the features in question
with v.category (take care of the type option) does not work in this
case?

Likely it does (I am asking on behalf on another person not subscribed here).
I wonder how to make it more obvious. And, if there is a best
practice example written in Python/PyGRASS?

with pygrass at the moment the pseudo code is something like:

{{{
with VectorTopo('yourvectormap', mode='r') as vect:
    for line in vect.viter('lines'):
        # do something with line
        pass
    for area in vect.viter('areas'):
        # do something with area
        pass
}}}

but I'm thinking to change how to iter between vector features to make
the distinction between topological and not topological features
clearer, something like:

{{{
with VectorTopo('yourvectormap', mode='r') as vect:
    for line in vect.features.lines:
        # do something with line
        pass
    for area in vect.topo.areas: # nodes, centroid, etc.
        # do something with area
        pass
}}}

But I'm still thinking on it...

Best regards

Pietro