Re: [GRASS-user] Directed vector networks (e.g. river networks)
Hi Johannes, On Friday 14 Jun 2013 11:03:04 Johannes Radinger wrote: Hi, as I am not very familiar with GRASS' vector capabilities maybe someone of you has some ideas. Is there the concept of directed vector networks e.g describing river networks with flow direction implemented in GRASS? Each line in GRASS is just an array of points, therefore for each line you have a direction from the first point to the last. If the direction is not correct you can change with reverse. A possible way to check the right direction using pygrass is (note, not tested, and pygrass is only available in grass7): {{{ from grass.pygrass.vector import VectorTopo from grass.pygrass.raster import RasterRow from grass.pygrass.gis.region import Region def check_line(line, elevation, region): first = elevation.get_value(line[0], region) last = elevation.get_value(line[-1], region) if first last: line.reverse() return line def check_direction(vectorname, elevname, outputname): Check if the direction of a river network is correct river = VectorTopo(vectorname) river.open() newriver = VectorTopo(outputname) newriver.open('w', tab_cols=river.table.columns.items()) elevation = RasterRow(elevname) elevation.open() region = Region() for line in river: newline = check_line(line, elevation, region) newriver.write(newline, attrs=line.attrs.values()) newriver.table.conn.commit() river.close() newriver.close() elevation.close() check_direction('river', 'elevation', 'river_checked') }}} Of course you can implement the same in C. For the other questions I'm not sure which is the best way to follow. All the best. Pietro ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Directed vector networks (e.g. river networks)
Pietro wrote: A possible way to check the right direction using pygrass is ... Of course you can implement the same in C. also try 'd.vect display=dir' to draw arrows on lines showing direction. Hamish ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Directed vector networks (e.g. river networks)
On Fri, Jun 14, 2013 at 11:03 AM, Johannes Radinger johannesradin...@gmail.com wrote: Hi, as I am not very familiar with GRASS' vector capabilities maybe someone of you has some ideas. Is there the concept of directed vector networks e.g describing river networks with flow direction implemented in GRASS? r.stream.extract produces a vector network with the direction of the lines corresponding to the flow direction. I am looking for a way that counts all barriers when routing from a starting point in the network And I'd like to get the number of barriers that are downstream and those that are upstream a given point. Or is there a way to cut a network into two parts where one is automatically detected as upstream while the other one is declared as the downstream network? Maybe the linear referencing system can help to count barriers. For separate upstream/downstream analysis, you could use vector network analysis tools and make use of the line direction: if want to go only upstream, set forward costs to -1, if you want to go only downstream, set backward costs to -1. Furthermore I am interested in calculating stream order for such dendritic networks. I saw the v.strahler add on, is there also an add on that calculates other types of stream order (here I am most interested in a vector based Shreve's stream order like as already implemented in r.stream.order). You could use r.stream.extract to produce both a raster and a vector river network, then run r.stream.order on the river raster and update the attributes of the vector with the desired order using v.what.rast. HTH, Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Directed vector networks (e.g. river networks)
On Fri, Jun 14, 2013 at 11:59 AM, Markus Metz markus.metz.gisw...@gmail.com wrote: On Fri, Jun 14, 2013 at 11:03 AM, Johannes Radinger johannesradin...@gmail.com wrote: Hi, as I am not very familiar with GRASS' vector capabilities maybe someone of you has some ideas. Is there the concept of directed vector networks e.g describing river networks with flow direction implemented in GRASS? r.stream.extract produces a vector network with the direction of the lines corresponding to the flow direction. I am looking for a way that counts all barriers when routing from a starting point in the network And I'd like to get the number of barriers that are downstream and those that are upstream a given point. Or is there a way to cut a network into two parts where one is automatically detected as upstream while the other one is declared as the downstream network? Maybe the linear referencing system can help to count barriers. Thank your for that info. I am totally unfamiliar with the LRS system, so I'll look into that and do some reading... :) For separate upstream/downstream analysis, you could use vector network analysis tools and make use of the line direction: if want to go only upstream, set forward costs to -1, if you want to go only downstream, set backward costs to -1. What tool of vector network analysis tool are you thinking of? can you given an example, e.g. to extract the enitre network upstream a given point? Furthermore I am interested in calculating stream order for such dendritic networks. I saw the v.strahler add on, is there also an add on that calculates other types of stream order (here I am most interested in a vector based Shreve's stream order like as already implemented in r.stream.order). You could use r.stream.extract to produce both a raster and a vector river network, then run r.stream.order on the river raster and update the attributes of the vector with the desired order using v.what.rast. Yes I also thought of using the really nice r.stream.* toolbox, although it is somehow inconvinient to transform to and from raster/vector just to get the network topological factor stream order. Theoretically, from a directed e.g. stream network that does not include cycles it should be possible to generate a stream order map, but probably that needs quite some knowledge abouot GRASS' network system and programming skills. Maybe a future add-on :) /Johannes HTH, Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Directed vector networks (e.g. river networks)
On Fri, Jun 14, 2013 at 4:18 PM, Johannes Radinger johannesradin...@gmail.com wrote: On Fri, Jun 14, 2013 at 11:59 AM, Markus Metz markus.metz.gisw...@gmail.com wrote: On Fri, Jun 14, 2013 at 11:03 AM, Johannes Radinger johannesradin...@gmail.com wrote: Hi, as I am not very familiar with GRASS' vector capabilities maybe someone of you has some ideas. Is there the concept of directed vector networks e.g describing river networks with flow direction implemented in GRASS? r.stream.extract produces a vector network with the direction of the lines corresponding to the flow direction. I am looking for a way that counts all barriers when routing from a starting point in the network And I'd like to get the number of barriers that are downstream and those that are upstream a given point. Or is there a way to cut a network into two parts where one is automatically detected as upstream while the other one is declared as the downstream network? Maybe the linear referencing system can help to count barriers. Thank your for that info. I am totally unfamiliar with the LRS system, so I'll look into that and do some reading... :) Maybe r.cost could also work: set stream segments to zero and barriers (barrier cells must be on the stream network) to 1. Cumulative costs would then be equal to the number of barriers. For separate upstream/downstream analysis, you could use vector network analysis tools and make use of the line direction: if want to go only upstream, set forward costs to -1, if you want to go only downstream, set backward costs to -1. What tool of vector network analysis tool are you thinking of? can you given an example, e.g. to extract the enitre network upstream a given point? v.net.alloc: Add two columns to the vector network table (layer must be the layer of the lines), one for line length, one for blocking. Upload lline length to the column for line length, Set the blocking column to -1. Run v.net.alloc, use the length column as forward cost as the blocking column as backward cost. This should give you the network downstream of the given point. Using the length column as backward cost as the blocking column as forward cost should give you the network upstream of the given point. Furthermore I am interested in calculating stream order for such dendritic networks. I saw the v.strahler add on, is there also an add on that calculates other types of stream order (here I am most interested in a vector based Shreve's stream order like as already implemented in r.stream.order). You could use r.stream.extract to produce both a raster and a vector river network, then run r.stream.order on the river raster and update the attributes of the vector with the desired order using v.what.rast. Yes I also thought of using the really nice r.stream.* toolbox, although it is somehow inconvinient to transform to and from raster/vector just to get the network topological factor stream order. Theoretically, from a directed e.g. stream network that does not include cycles it should be possible to generate a stream order map, but probably that needs quite some knowledge abouot GRASS' network system and programming skills. Maybe a future add-on :) You don't need to transform to and from raster/vector. Ask r.stream.extract to produce both a raster and a vector output, then run r.stream.order on the river raster and update the attributes of the vector with the output of r.stream.order using v.what.rast. Markus M ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user