[GRASS-user] visited lines

Hi list,
I have a maybe stupid question, but I should identify (by category) the net lines visited from going to one point to another along a net. I tried the v.net module, but I’m not colpletely sure to have understood what the ‘nreport’ option for the parameter ‘operation’ does.
I don’t necessarily need to generate the path, I should only identify the visited lines by printing category…

Any hint?

Annalisa

On 20/03/14 11:41, Annalisa Minelli wrote:

Hi list,
I have a maybe stupid question, but I should identify (by category) the
net lines visited from going to one point to another along a net. I
tried the v.net <http://v.net> module, but I'm not colpletely sure to
have understood what the 'nreport' option for the parameter 'operation'
does.
I don't necessarily need to generate the path, I should only identify
the visited lines by printing category..

I don't think there is a direct way of doing this (except possibly by activating debugging and then filtering out the relevant info), but you can do it through a combination of v.net.path, v.category and v.distance. E.g. (using the North Carolina demo dataset):

v.net -s streets_wake points=schools_wake out=network op=connect thresh=500
echo "1 166 1" | v.net.path -s network out=mypath
#The result is a map with the same category value for all segments, but we need different category values for each segment

v.category mypath op=del out=temp
v.category -t temp op=add out=mypath_segs

v.distance -p from=mypath_segs to=network upload=cat col=segcat

#The result should be (I didn't verify) the list of the cat values of the lines in network that the path goes through.
#If you need another attribute of these lines, just use upload=attr and tocolumn= in the v.distance call.

Moritz

On 24/03/14 17:10, Moritz Lennert wrote:

On 20/03/14 11:41, Annalisa Minelli wrote:

Hi list,
I have a maybe stupid question, but I should identify (by category) the
net lines visited from going to one point to another along a net. I
tried the v.net <http://v.net> module, but I'm not colpletely sure to
have understood what the 'nreport' option for the parameter 'operation'
does.
I don't necessarily need to generate the path, I should only identify
the visited lines by printing category..

I don't think there is a direct way of doing this

I just filed an enhancement wish for that:

https://trac.osgeo.org/grass/ticket/2227

Moritz

Hello Moritz,
I tried your solution and since I generated the path using the same v.net.path with the same -s flag (which preserves the segments) that you suggest, when I do the v.distance trying to “copy” the attribute cat from the net segments it seems not to work properly - I mean, it copies “something” but that “something” is wrong in the sense that it takes the category of the element NEAR the studied one, not ‘under’ even specifying a dmax=0…

v.net.path input=‘gridCat’ output=‘tmpPath2’ file=‘tmpCoord2’ -s

v.db.droptable map=‘tmpPath2’ -f

v.category input=‘tmpPath2’ output=‘tmpPath4a’ option=‘del’

v.category input=‘tmpPath4a’ output=‘tmpPath2’ option=‘add’)

v.db.addtable map=‘tmpPath2’ columns=‘cat integer,tmpcat integer’
v.distance from=‘tmpPath2’ from_type=‘line’ to=‘gridCat’ to_type=‘line’ upload=‘cat’ column=‘tmpcat’ dmax=0

here a pic of my situation: http://oi62.tinypic.com/2epopcj.jpg
in red the tmpPath2 and tmpcat value as label
in black the gridCat and the value of the category as label

Thanks for all,
Annalisa

ps. …and for the request too :slight_smile:

···

2014-03-24 17:10 GMT+01:00 Moritz Lennert <mlennert@club.worldonline.be>:

On 20/03/14 11:41, Annalisa Minelli wrote:

Hi list,
I have a maybe stupid question, but I should identify (by category) the
net lines visited from going to one point to another along a net. I

tried the v.net <http://v.net> module, but I’m not colpletely sure to

have understood what the ‘nreport’ option for the parameter ‘operation’
does.
I don’t necessarily need to generate the path, I should only identify
the visited lines by printing category…

I don’t think there is a direct way of doing this (except possibly by activating debugging and then filtering out the relevant info), but you can do it through a combination of v.net.path, v.category and v.distance. E.g. (using the North Carolina demo dataset):

v.net -s streets_wake points=schools_wake out=network op=connect thresh=500
echo “1 166 1” | v.net.path -s network out=mypath
#The result is a map with the same category value for all segments, but we need different category values for each segment

v.category mypath op=del out=temp
v.category -t temp op=add out=mypath_segs

v.distance -p from=mypath_segs to=network upload=cat col=segcat

#The result should be (I didn’t verify) the list of the cat values of the lines in network that the path goes through.
#If you need another attribute of these lines, just use upload=attr and tocolumn= in the v.distance call.

Moritz

On 24/03/14 18:24, Annalisa Minelli wrote:

Hello Moritz,
I tried your solution and since I generated the path using the same
v.net.path with the same -s flag (which preserves the segments) that you
suggest, when I do the v.distance trying to "copy" the attribute cat
from the net segments it seems not to work properly - I mean, it copies
"something" but that "something" is wrong in the sense that it takes the
category of the element NEAR the studied one, not 'under' even
specifying a dmax=0..

v.net.path input='gridCat' output='tmpPath2' file='tmpCoord2' -s
v.db.droptable map='tmpPath2' -f
v.category input='tmpPath2' output='tmpPath4a' option='del'
v.category input='tmpPath4a' output='tmpPath2' option='add')
v.db.addtable map='tmpPath2' columns='cat integer,tmpcat integer'
v.distance from='tmpPath2' from_type='line' to='gridCat' to_type='line'
upload='cat' column='tmpcat' dmax=0

here a pic of my situation: http://oi62.tinypic.com/2epopcj.jpg
in red the tmpPath2 and tmpcat value as label
in black the gridCat and the value of the category as label

The man page says "For lines to lines, say line A to line B, v.distance calculates the shortest distance of each vertex in A with each segment (not vertex) in B. The module then calculates the shortest distance of each vertex in B to each segment in A. The overall shortest distance of A points to B segments and B points to A segments is used. Additionally, v.distance checks for intersections. In case of intersections, the first intersection found is used and the distance set to zero."

I guess that identity is not the same as intersection...
Markus ?

Moritz