On 06/05/15 22:12, knussear wrote:
Interestingly 4 years later and using V.split in grass7 and I'm still having
the same problem....

tried the v.category solution and the cats were never deleted.

Are you sure ? In the original thread, the check for success was wrong [1]: v.db.select checks the attached attribute table (which v.split does not modify), not the categories present in the features.

Here's a working example using a simple vector map with three lines:

v.split test_line out=line_test_split length=5000

v.category line_test_split op=report
Layer/table: 1/line_test_split
type       count        min        max
point          0          0          0
line          46          2          4
boundary       0          0          0
centroid       0          0          0
area           0          0          0
face           0          0          0
kernel         0          0          0
all           46          2          4

Now, two options:

1) You want to keep the category values of the original lines, but also add individual category values for the new segements. Here GRASS's layer paradigm comes in handy, allowing you to create a second layer of information:

#create second information layer containing new individual category values for the segments
v.category line_test_split out=line_test_split_w_lay2 layer=2 op=add

v.category line_test_split_w_lay2 op=report
Layer/table: 1/line_test_split_w_lay2
type       count        min        max
point          0          0          0
line          46          2          4
boundary       0          0          0
centroid       0          0          0
area           0          0          0
face           0          0          0
kernel         0          0          0
all           46          2          4
Layer/table: 2/line_test_split_w_lay2_2
type       count        min        max
point          0          0          0
line          46          1         46
boundary       0          0          0
centroid       0          0          0
area           0          0          0
face           0          0          0
kernel         0          0          0
all           46          1         46

Now you can add a new attribute table to the second layer:

v.db.addtable line_test_split_w_lay2 layer=2

If you want to integrate the old categories (or anything else from the original attribute table) into the attribute table of the new segments:

v.db.addcolumn line_test_split_w_lay2 col="old_cat int" layer=2
v.to.db line_test_split_w_lay2 layer=2 query_layer=1 op=query query_col=cat col=old_cat

v.db.select line_test_split_w_lay2 layer=2
cat|old_cat
1|2
2|2
3|2
4|2
5|2
6|2
7|2
8|2
9|2
10|2
11|2
12|2
13|2
14|2
15|2
16|2
17|3
18|3
19|3
20|3
21|3
etc...

2) You just need the segments with individual category values, but not the old line categories, nor the old attribute table:

#delete old cats, don't keep old attribute table to avoid confusion
v.category -t line_test_split op=del cat=-1 out=line_test_split_wo_cats

#add new cats
v.category line_test_split_wo_cats out=line_test_split_w_new_cats op=add

#now, if necessary create new attribute table prefilled with cat values
v.db.addtable line_test_split_w_new_cats

My system
will also not install the v.to.equidist add on.

Which version of GRASS are you using. The addon was developed for GRASS 6.

It is a simple shell script which you can download from [2], but I haven't checked if it will run as-is in GRASS 7


Moritz

[1] http://lists.osgeo.org/pipermail/grass-user/2011-October/062318.html
[2] https://raw.githubusercontent.com/amuriy/GRASS-scripts/master/v.to.equidist

_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to