[GRASS-user] Add DB entries to vector line (after v.split)
Alexander Muriy
amuriy at gmail.com
Fri May 8 11:37:01 PDT 2015
<v.to.equidist
<https://raw.githubusercontent.com/amuriy/GRASS-scripts/master/v.to.equidist>>
addon doesn't work under GRASS 7 (only 6.4.*). But I still have plans to
rewrite it in Python :) You could also try the addon <v.fixed.segmentpoints>,
it works similary.
2015-05-08 20:10 GMT+03:00 Ken Nussear <knussear at mac.com>:
> Thanks very much, that is all working well. I did try the addon you
> mention, but using grass7 it wont install in either linux or mac os
>
> I'm having some trouble with the final layer though when trying to sample
> a raster....
>
>
> Using this command
>
> v.what.rast map=TSELinesSplit500_w_lay2 at PERMANENT type=centroid
> raster=a250m_ATI at MojaveCovariates_250m column=RC1
>
> WARNING: No record for category 0 in table <TSELinesSplit500_w_lay2>
>
> Any idea why I have no category 0?
>
> Ken
>
> Moritz Lennert <mlennert at club.worldonline.be>
> May 7, 2015 at 2:54 AM
> 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
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150508/ce0cf711/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: compose-unknown-contact.jpg
Type: image/jpeg
Size: 770 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150508/ce0cf711/attachment.jpg>
More information about the grass-user
mailing list