[GRASS-user] Assign attributes of start and enpoints to connecting lines

Micha Silver micha at arava.co.il
Thu Dec 9 11:05:50 EST 2010


On 09/12/2010 16:38, Hanlie Pretorius wrote:
> Hi,
>
> I'm working in GRASS 6.4.0 on Windows XP.
>
> I'm creating a hydrological model and am using GIS to prepare the data.
>
> I've split my river layer into about 100 segments and I've digitised
> the start and end point of each river segment on a points layer.
>
> For the points layer, I calculate a 'name' from a prefix and a sequental number.
>
> What I would like to do, is to assign for each river segment the name
> of the start node and the name of the end node to the attribute table
> of the river segment layer.
>
> Can anyone give me pointers on how to do this?
I think that v.distance can do this. begin by adding two 
attrib columns to your river layer, one for the start node 
label, and one for the end node label. Then run v.distance 
twice to get the labels from the 'name' column from each of 
the node layers. Finally concatenate the two labels together. 
So...
# Add columns
v.db.addcol rivers col="start_node varchar(8), end_node 
varchar(8), label varchar(16)"
# Use whatever size strings you need
v.distance from=rivers to=end_nodes from_type=line 
to_type=point upload=to_attrib column=name to_col=end_node
# and again for the start_nodes
#Now merge the columns
echo "UPDATE rivers SET label=(start_node + end_node)" | 
db.execute
# I'm not sure the above '+' will work on all database 
connections. With dbf probably not...

> Thanks
> Hanlie
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
> This mail was received via Mail-SeCure System.
>
>


-- 
Micha Silver
http://www.surfaces.co.il/
Arava Development Co.  +972-52-3665918



More information about the grass-user mailing list