[GRASS-user] vector segment lengths
Moritz Lennert
mlennert at club.worldonline.be
Wed Dec 5 22:54:28 PST 2018
Am 5. Dezember 2018 22:14:27 MEZ schrieb Ken Mankoff <mankoff at gmail.com>:
>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"
Your absolutely right, you obviously need to add an attribute table to layer 2 first. Sorry for that.
>
>> 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.
Just give it a try. We can always suggest amendments if necessary.
>
>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
You can use v.to.db with layer=2 option=query query_layer=1 query_column=cat to load the original cat value to the table of layer 2.
Moritz
More information about the grass-user
mailing list