Hi everybody,<br>in precedent mails , I ask for split polyline vector with a point vector to create a new polyline vector. <br>I wrote a little shell bash to resolve the problem (this script is not yet finish). Be tolerant, I'm a newbie in GRASS and linux script; there are no warning (no verification of the input layer...) in the script, I've not finished the end. I post you this script to have any suggestion of the way I choose to solve my problem, so take a look and If you have any ideas to improve my script don't hesitate to post me a message
<br><br><br>#!/bin/bash<br>#launch this script on GRASS <br>#job of this script: split polylines with a vector of points<br>#and create a new polylines vector<br>#use of GRASS Add on: v.out.ascii.db<br>mkdir $HOME/provseg/ #temporary datafile created
<br>echo "enter the name of the polylines vector "<br>read rh<br>echo " "<br>echo "the choosen polyline vector is $rh"<br>#the point vector was an esri shapefile with only one column which will be delete in the middle of the script
<br>echo "enter the name of the points vector : "<br>read exut<br>echo "the choosen point vector is $exut"<br>echo " enter a name for the new polyline vector : "<br>read rhfin<br>echo "the name of the new polyline vector will be : $rhfin"
<br>echo " "<br>echo "***************"<br>echo "add columns lcat, along, x and y to the points vector"<br>echo " and calcul of x y coordinates of the points vector"<br>echo "ALTER TABLE $exut ADD COLUMN lcat INTEGER"|db.execute
<br>echo "ALTER TABLE $exut ADD COLUMN along DOUBLE"|db.execute<br>echo "ALTER TABLE $exut ADD COLUMN x DOUBLE"|db.execute<br>echo "ALTER TABLE $exut ADD COLUMN y DOUBLE"|db.execute<br>#calcul of x y coordinates of the points vector
<br>v.to.db map=$exut type=point option=coor units=me column=x,y<br>echo " "<br>echo "***************"<br>echo "distance calculation beetween polyline vector and points vector"<br>#find the cat number of the segment where the point is on
<br>v.distance from=$exut to=$rh from_type=point to_type=line upload=cat column=lcat<br>#find the distance beetween the beginning of the segment and the point<br>v.distance from=$exut to=$rh from_type=point to_type=line upload=to_along column=along
<br>echo " "<br>echo "***************"<br>echo "export of the cat of the segments"<br>#segcat file with points attributs:x,y,cat of the segment<br>v.out.ascii.db input=$exut output=$HOME/provseg/segcat columns=lcat
<br>#segcat2 file with only cat of the segment<br>cut -d"|" -f4 $HOME/provseg/segcat>$HOME/provseg/segcat2<br>echo " "<br>echo "***************"<br>echo "extraction of the selected segments"
<br>#extraction from rh to rh2 of the selected segment with the list of the cat in segcat2<br>v.extract input=rh output=rh2 type=line file=$HOME/provseg/segcat2<br>echo " "<br>echo "***************"<br>
echo "export of the point of the segment"<br>echo "and calcul of the distance beetween these points and the beginning of the segment; results in layer 2"<br>#export of these points from rh2 to rh3<br>v.to.points
input=rh2 type=line output=rh3<br>echo " "<br>echo "***************"<br>echo "calcul of the x,y coordinate of these points"<br>echo "ALTER TABLE rh3_2 ADD COLUMN x DOUBLE"|db.execute
<br>echo "ALTER TABLE rh3_2 ADD COLUMN y DOUBLE"|db.execute<br>#calcul of the x y coordinate<br>v.to.db map=rh3 type=point layer=2 option=coor units=me column=x,y<br>echo " "<br>echo "***************"
<br>echo "creation of a column TYPE in the vectors points"<br>echo "ALTER TABLE rh3_2 ADD COLUMN type VARCHAR(10)"|db.execute<br>echo "ALTER TABLE $exut ADD COLUMN type VARCHAR(10)"|db.execute
<br>#in rh3, TYPE has the valor: rh<br>echo "UPDATE rh3_2 SET type='rh'"|db.execute<br>#in $exut, TYPE has the valor: exut<br>echo "UPDATE $exut SET type='exut'"|db.execute<br>echo " "<br>echo "***************"
<br>echo "export of the points attributs of rh3 and exut<br>#segcat3 file has points and attributs of rh3<br>db.select -c table=rh3_2>$HOME/provseg/segcat3<br>#segcat4 file has points and attributs of exut<br>db.select
-c table=pt_exut>$HOME/provseg/segcat4<br>#in segcat5 file we deletes the esri shp column of exut<br>cut -d"|" -f1,3,4,5,6,7 $HOME/provseg/segcat4>$HOME/provseg/segcat5<br>#kill segcat4<br>rm $HOME/provseg/segcat4
<br>echo " "<br>echo "***************"<br>echo "merge all the points of rh and exut"<br>#sort segcat3 file by cat ; creation of segcat30<br>sort -k2n -t'|' $HOME/provseg/segcat3 >$HOME/provseg/segcat30
<br>#sort segcat5 file by cat ; cretion of segcat50<br>sort -k2n -t'|' $HOME/provseg/segcat5 >$HOME/provseg/segcat50<br>#sort an merge segcat30 and segcat50 by cat and after by distance ; creation of segcat6<br>sort -m -k2n -k3g -t'|' $HOME/provseg/segcat30 $HOME/provseg/segcat50>$HOME/provseg/segcat6
<br>#kill segcat30 and segcat50<br>rm $HOME/provseg/segcat30<br>rm $HOME/provseg/segcat50<br>#delete the first column (cat of the points) in segcat6 ; creation of segcat9<br>cut -d"|" -f2,3,4,5,6 $HOME/provseg/segcat6>$HOME/provseg/segcat9
<br>#kill segcat6<br>#the next line ar suggestions of the way I want to choose to finish<br>#???????????????????????????????????????<br>#???????????????????????????????????????<br>#creation of the input ascii file for the creation of the new polyline vector"
<br>#in the old vector file, we must delete the selected segment<br>#merge the new and th old polyline vector together, build topology<br>#kill the temporary files <br><br>Cheers<br>Mick<br><br><br><br><br>