Hi all
I've run v.net.salesman, which generates a nice route, but what I really need is the sequence of nodes that the solution visits, in the correct order. How can I obtain that from v.net.salesman outputs?
Gavin
Hi all
I've run v.net.salesman, which generates a nice route, but what I really need is the sequence of nodes that the solution visits, in the correct order. How can I obtain that from v.net.salesman outputs?
Gavin
On 28/04/12 10:22, Gavin Fleming wrote:
Hi all
I've run v.net.salesman, which generates a nice route, but what I really
need is the sequence of nodes that the solution visits, in the correct
order. How can I obtain that from v.net.salesman outputs?
How about v.select ain=nodes bin=route ?
Moritz
Here’s my route - it’s easy enough to see the nodes but how to extract them in the order they need to be visited?
v.select just selects them, but not in route order.
--
regards
Gavin
Gavin Fleming
[http://afrispatial.co.za](http://afrispatial.co.za)
t: 0218620670
c: 0845965680
f: 0866164820
On 30/04/12 11:10, Gavin Fleming wrote:
Here's my route - it's easy enough to see the nodes but how to extract
them in the order they need to be visited?v.select just selects them, but not in route order.
There's currently no official way of getting the node ids in order. However, there is a workaround that allows you to get that info using debug output:
[using the NC demo data]
v.net in=streets_wake points=schools_wake out=streets_with_schools operation=connect thresh=50
g.gisenv set=DEBUG=2
v.net.salesman in=streets_with_schools out=salesroute ccats=1-999
The last line of the output should look like this, giving you the category values of the nodes in route order:
Nodes' categories (layer 2, 994 nodes):
42,41,164,38,126,15,52,84,16,55,17,157,60,6,61,8,1,76,72,46,47,68,24,25,26,28
It should be fairly easy to add an option to v.net.salesman to output this information. Please file a wish in the bug tracker, also explaining which output format would be most suitable.
Moritz
On 30/04/2012 10:21, Moritz Lennert wrote:
On 28/04/12 10:22, Gavin Fleming wrote:
Hi all
I've run v.net.salesman, which generates a nice route, but what I really
need is the sequence of nodes that the solution visits, in the correct
order. How can I obtain that from v.net.salesman outputs?How about v.select ain=nodes bin=route ?
Moritz
--
regardsGavin
Gavin Fleming
http://afrispatial.co.za
t: 0218620670
c: 0845965680
f: 0866164820
On 30/04/12 11:30, Moritz Lennert wrote:
On 30/04/12 11:10, Gavin Fleming wrote:
Here's my route - it's easy enough to see the nodes but how to extract
them in the order they need to be visited?v.select just selects them, but not in route order.
There's currently no official way of getting the node ids in order.
However, there is a workaround that allows you to get that info using
debug output:[using the NC demo data]
v.net in=streets_wake points=schools_wake out=streets_with_schools
operation=connect thresh=50
g.gisenv set=DEBUG=2
v.net.salesman in=streets_with_schools out=salesroute ccats=1-999
Sorry, above is not totally correct: you actually do not need to set the DEBUG variable, just setting the verbose flag is enough:
v.net in=streets_wake points=schools_wake out=streets_with_schools
operation=connect thresh=50
v.net.salesman in=streets_with_schools out=salesroute ccats=1-999 --v
But still, this should probably be upgraded from a hidden feature to a real option.
Moritz
Thanks Moritz, your tip saved the day.
I’ve added this to http://trac.osgeo.org/grass/ticket/1650
--
regards
Gavin
Gavin Fleming
[http://afrispatial.co.za](http://afrispatial.co.za)
t: 0218620670
c: 0845965680
f: 0866164820
The last line of the output should look like this, giving you the category values of the nodes in route order:
Nodes' categories (layer 2, 994 nodes):
42,41,164,38,126,15,52,84,16,55,17,157,60,6,61,8,1,76,72,46,47,68,24,25,26,28
How could I parse the 'Nodes categories' array from the debug output (I'm stuck with 6.4.1 for now)? More specifically , I need to do it in Python with grass.script.
Gavin
this is how I did it:
grass.run_command(‘g.gisenv’, set=“DEBUG=2”)
p = grass.pipe_command(‘v.net.salesman’, overwrite = True, _in=‘network_clean’, output=‘salesman’, nlayer=1, ccats=cats)
result =
for line in p.stdout:
result.append(line)
p.wait()
print result[-2] #this is where the node sequence sits in the debug output
On 8 May 2012 00:43, Gavin Fleming <gavin@afrispatial.co.za> wrote:
The last line of the output should look like this, giving you the category values of the nodes in route order:
Nodes’ categories (layer 2, 994 nodes):
42,41,164,38,126,15,52,84,16,55,17,157,60,6,61,8,1,76,72,46,47,68,24,25,26,28How could I parse the ‘Nodes categories’ array from the debug output (I’m stuck with 6.4.1 for now)? More specifically , I need to do it in Python with grass.script.
Gavin