[GRASS-SVN] r71599 - grass/trunk/raster/r.stream.extract
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 27 12:56:40 PDT 2017
Author: mmetz
Date: 2017-10-27 12:56:40 -0700 (Fri, 27 Oct 2017)
New Revision: 71599
Modified:
grass/trunk/raster/r.stream.extract/close.c
grass/trunk/raster/r.stream.extract/r.stream.extract.html
Log:
r.stream.extract: add network id to vector output
Modified: grass/trunk/raster/r.stream.extract/close.c
===================================================================
--- grass/trunk/raster/r.stream.extract/close.c 2017-10-27 15:17:07 UTC (rev 71598)
+++ grass/trunk/raster/r.stream.extract/close.c 2017-10-27 19:56:40 UTC (rev 71599)
@@ -30,6 +30,7 @@
struct Cell_head window;
double north_offset, west_offset, ns_res, ew_res;
int next_cat;
+ int *network_id;
G_message(_("Writing vector map <%s>..."), stream_vect);
@@ -37,6 +38,9 @@
G_fatal_error(_("Unable to create vector map <%s>"), stream_vect);
nodestack = (struct sstack *)G_malloc(stack_step * sizeof(struct sstack));
+ network_id = G_malloc((n_stream_nodes + 1) * sizeof(int));
+ for (i = 0; i <= n_stream_nodes; i++)
+ network_id[i] = 0;
Points = Vect_new_line_struct();
Cats = Vect_new_cats_struct();
@@ -58,6 +62,7 @@
if (!stream_id)
continue;
+ network_id[stream_id] = i + 1;
Vect_reset_line(Points);
Vect_reset_cats(Cats);
@@ -106,6 +111,7 @@
if (done) {
G_debug(3, "write stream segment");
+ network_id[stream_id] = i + 1;
Vect_reset_line(Points);
Vect_reset_cats(Cats);
@@ -178,7 +184,7 @@
G_debug(1, "database: %s", Fi->database);
sprintf(buf,
- "create table %s (%s integer, stream_type varchar(20), type_code integer)",
+ "create table %s (%s integer, stream_type varchar(20), type_code integer, network integer)",
Fi->table, cat_col_name);
db_set_string(&dbsql, buf);
@@ -200,10 +206,10 @@
/* stream nodes */
for (i = 1; i <= n_stream_nodes; i++) {
- sprintf(buf, "insert into %s values ( %lld, \'%s\', %d )",
+ sprintf(buf, "insert into %s values ( %lld, \'%s\', %d, %d )",
Fi->table, i,
(stream_node[i].n_trib > 0 ? "intermediate" : "start"),
- (stream_node[i].n_trib > 0));
+ (stream_node[i].n_trib > 0), network_id[i]);
db_set_string(&dbsql, buf);
@@ -228,6 +234,7 @@
Vect_close(&Out);
G_free(nodestack);
+ G_free(network_id);
return 1;
}
Modified: grass/trunk/raster/r.stream.extract/r.stream.extract.html
===================================================================
--- grass/trunk/raster/r.stream.extract/r.stream.extract.html 2017-10-27 15:17:07 UTC (rev 71598)
+++ grass/trunk/raster/r.stream.extract/r.stream.extract.html 2017-10-27 19:56:40 UTC (rev 71599)
@@ -148,14 +148,15 @@
and points. Points are written at the start location of each stream
segment and at the outlet of a stream network. In layer 1, categories
are unique IDs, identical to the cell value of the raster output. The
-attribute table for layer 1 holds information about the type of stream
-segment: start segment, or intermediate segment with
-tributaries. Columns are <tt>cat int, stream_type varchar(), type_code
-int</tt>. The encoding for type_code is 0 = start, 1 =
-intermediate. In layer 2, categories are identical to type_code in
-layer 1 with additional category 2 = outlet for outlet points. Points
-with category 1 = intermediate in layer 2 are at the location of
-confluences.
+attribute table for layer 1 holds information about the type of stream
+segment: start segment, or intermediate segment with tributaries, and
+about the stream network this stream or node belongs to. Columns are
+<tt>cat int,stream_type varchar(),type_code int,network int</tt>. The
+network attribute is the network ID of the stream/node. The encoding
+for type_code is 0 = start, 1 = intermediate. In layer 2, categories
+are identical to type_code in layer 1 with additional category 2 =
+outlet for outlet points. Points with category 1 = intermediate in
+layer 2 are at the location of confluences.
<h2>EXAMPLE</h2>
More information about the grass-commit
mailing list