[GRASS-user] vector segment lengths

Ken Mankoff mankoff at gmail.com
Wed Dec 5 13:14:27 PST 2018


Hi Moritz,

On 2018-11-29 at 04:38 -0800, Moritz Lennert <mlennert at club.worldonline.be> wrote:
> If you want the length of each segment, you will have to attribute 
> different category values to all of them. The best is to this on a 
> separate layer, using v.category
>
> v.category v_split op=add layer=2 output=v_split_2
>
> then you can run your above commands on that layer:
>
> v.db.addcolumn map=v_split_2 column="length double precision layer=2

> v.to.db map=v_split_2 type=line option=length columns=length 
> units=meters layer=2

The code you provided does not work for me, but does if I change you 'v.db.addcolumn' command to

v.db.addtable map=v_split_2 layer=2 columns="length double precision"

> This info should probably somehow go into the man page of v.split.

I would edit the man page and upload a patch to Trac but am not confident enough I understand what you've suggested (yet) to document it for others.

Anyway, afterwards, I have the following tables (from db.tables):

v
v_split
v_split_2
v_split_2_2

Now I need to select the split segments in v_split_2_2 but aggregate them based on the larger segments they came from (in v_split_2). I don't see how these tables are connected at this point, nor how to join them. The categories are unique:

v.db.select map=v_split_2 layer=1 | head -n3
cat|id|label
1|1|
2|1|

v.db.select map=v_split_2 layer=2 | head -n3
cat|length
1|100
2|100


  -k.


More information about the grass-user mailing list