[GRASS-SVN] r67918 - grass/trunk/vector/v.to.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Feb 22 01:20:45 PST 2016


Author: mmetz
Date: 2016-02-22 01:20:45 -0800 (Mon, 22 Feb 2016)
New Revision: 67918

Modified:
   grass/trunk/vector/v.to.rast/do_areas.c
   grass/trunk/vector/v.to.rast/main.c
   grass/trunk/vector/v.to.rast/v.to.rast.html
   grass/trunk/vector/v.to.rast/vect2rast.c
Log:
v.to.rast: fix #2239

Modified: grass/trunk/vector/v.to.rast/do_areas.c
===================================================================
--- grass/trunk/vector/v.to.rast/do_areas.c	2016-02-21 11:05:12 UTC (rev 67917)
+++ grass/trunk/vector/v.to.rast/do_areas.c	2016-02-22 09:20:45 UTC (rev 67918)
@@ -80,7 +80,8 @@
 	    return -1;
 	}
 
-	G_plot_polygon(Points->x, Points->y, Points->n_points);
+	if (G_plot_polygon(Points->x, Points->y, Points->n_points) != 0)
+	    G_warning(_("Failed to plot polygon"));
     }
     G_percent(1, 1, 1);
     

Modified: grass/trunk/vector/v.to.rast/main.c
===================================================================
--- grass/trunk/vector/v.to.rast/main.c	2016-02-21 11:05:12 UTC (rev 67917)
+++ grass/trunk/vector/v.to.rast/main.c	2016-02-22 09:20:45 UTC (rev 67918)
@@ -52,7 +52,7 @@
     field_opt = G_define_standard_option(G_OPT_V_FIELD);
 
     type_opt = G_define_standard_option(G_OPT_V_TYPE);
-    type_opt->options = "point,line,area";
+    type_opt->options = "point,line,boundary,area";
     type_opt->answer = "point,line,area";
     type_opt->guisection = _("Selection");
     

Modified: grass/trunk/vector/v.to.rast/v.to.rast.html
===================================================================
--- grass/trunk/vector/v.to.rast/v.to.rast.html	2016-02-21 11:05:12 UTC (rev 67917)
+++ grass/trunk/vector/v.to.rast/v.to.rast.html	2016-02-22 09:20:45 UTC (rev 67918)
@@ -1,12 +1,18 @@
 <h2>DESCRIPTION</h2>
 
 <em>v.to.rast</em> transforms GRASS vector map layers into GRASS raster map
-layer format. Optionally, attributes can be converted into raster category
+layer format. Optionally, attributes can be converted to raster category
 labels.
 
 
 <h2>NOTES</h2>
 
+In order to avoid unexpected results, the type of vector features 
+should always be specified. The default is to convert all vector 
+features, but if only e.g. areas should be converted use 
+<em>type=area</em> rather than <em>type=point,line,area</em>.
+
+<p>
 <em>v.to.rast</em> will only affect data in areas lying
 inside the boundaries of the current geographic region.
 A grid cell belongs to the area where the grid cell center falls into.
@@ -55,8 +61,13 @@
 <p><p><b>Flow directions</b> are given in degrees counterclockwise from east.
 <p><p>Raster category labels are supported for all of <em>use=</em> except <em>use=z</em>.
 <p>
-The <b>-d</b> flag applies only to lines, the default is only those on the
-render path (thin line).
+The <b>-d</b> flag applies only to lines and boundaries, the default is 
+to set only those cells on the render path (thin line).
+<p>
+Boundaries (usually without categories) can be rasterized with
+<div class="code"><pre>
+v.to.rast type=boundary layer=-1 use=val
+</pre></div>
 
 <h2>EXAMPLES</h2>
 
@@ -72,7 +83,7 @@
 </pre></div>
 
 <div class="code"><pre>
-v.to.rast input=vect_map output=raster_map attribute_column=SPEED
+v.to.rast input=vect_map output=raster_map attribute_column=SPEED type=line
 </pre></div>
 
 <h3>Calculate stream directions from a river vector map (Spearfish)</h3>

Modified: grass/trunk/vector/v.to.rast/vect2rast.c
===================================================================
--- grass/trunk/vector/v.to.rast/vect2rast.c	2016-02-21 11:05:12 UTC (rev 67917)
+++ grass/trunk/vector/v.to.rast/vect2rast.c	2016-02-22 09:20:45 UTC (rev 67918)
@@ -133,8 +133,13 @@
 
 	G_debug(1, "%d areas sorted", nareas);
     }
+    if (nareas > 0 && dense) {
+	G_warning(_("Area conversion and line densification are mutually exclusive, disabling line densification."));
+	dense = 0;
+    }
 
-    nlines = 1;
+    nlines = Vect_get_num_primitives(&Map, ftype);
+    nplines_all = nlines;
     npasses = begin_rasterization(cache_mb, format, dense);
     pass = 0;
 
@@ -227,7 +232,7 @@
      * actual number of lines, currently unknown:
      * number of lines are within cat constraint
      * and overlap with current region */
-    if (nplines_all > 0)
+    if (nlines > 0 && nplines_all > 0)
 	G_message(_("Converted points/lines: %d of %d"), nlines, nplines_all);
 #endif
 



More information about the grass-commit mailing list