[GRASS-SVN] r59341 - grass/trunk/vector/v.what.rast

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 25 13:38:16 PDT 2014


Author: neteler
Date: 2014-03-25 13:38:16 -0700 (Tue, 25 Mar 2014)
New Revision: 59341

Modified:
   grass/trunk/vector/v.what.rast/main.c
   grass/trunk/vector/v.what.rast/v.what.rast.html
Log:
v.what.rast: centroid support added

Modified: grass/trunk/vector/v.what.rast/main.c
===================================================================
--- grass/trunk/vector/v.what.rast/main.c	2014-03-25 20:34:39 UTC (rev 59340)
+++ grass/trunk/vector/v.what.rast/main.c	2014-03-25 20:38:16 UTC (rev 59341)
@@ -28,7 +28,7 @@
 
 int main(int argc, char *argv[])
 {
-    int i, j, nlines, type, field, cat;
+    int i, j, nlines, type, field, cat, vtype;
     int fd;
 
     /* struct Categories RCats; */ /* TODO */
@@ -41,7 +41,7 @@
     char buf[2000];
     struct
     {
-	struct Option *vect, *rast, *field, *col, *where;
+	struct Option *vect, *rast, *field, *type, *col, *where;
     } opt;
     struct Flag *interp_flag, *print_flag;
     int Cache_size;
@@ -83,6 +83,10 @@
 
     opt.field = G_define_standard_option(G_OPT_V_FIELD);
 
+    opt.type = G_define_standard_option(G_OPT_V_TYPE);
+    opt.type->options = "point,centroid";
+    opt.type->answer = "point";
+
     opt.rast = G_define_standard_option(G_OPT_R_MAP);
     opt.rast->key = "raster";
     opt.rast->description = _("Name of existing raster map to be queried");
@@ -172,8 +176,9 @@
 	    G_warning(_("Raster type is float and column type is integer, some data lost!!"));
     }
 
+    vtype = Vect_option_to_types(opt.type);
     /* Read vector points to cache */
-    Cache_size = Vect_get_num_primitives(&Map, GV_POINTS);
+    Cache_size = Vect_get_num_primitives(&Map, vtype);
     /* Note: Some space may be wasted (outside region or no category) */
 
     cache = (struct order *)G_calloc(Cache_size, sizeof(struct order));
@@ -192,8 +197,9 @@
 	G_percent(i, nlines, 2);
 
 	/* check type */
-	if (!(type & GV_POINTS))
-	    continue;		/* Points only */
+	if (!(type & vtype))
+	    continue;		/* Points or centroids only */
+        G_debug(1, "line = %d type = %d", i, type);
 
 	/* check region */
 	if (!Vect_point_in_box(Points->x[0], Points->y[0], 0.0, &box)) {

Modified: grass/trunk/vector/v.what.rast/v.what.rast.html
===================================================================
--- grass/trunk/vector/v.what.rast/v.what.rast.html	2014-03-25 20:34:39 UTC (rev 59340)
+++ grass/trunk/vector/v.what.rast/v.what.rast.html	2014-03-25 20:38:16 UTC (rev 59341)
@@ -1,8 +1,8 @@
 <h2>DESCRIPTION</h2>
 
 <em>v.what.rast</em> retrieves raster value from a given raster map for each point
-stored in a given vector map. It can update a <b>column</b> in the linked vector
-attribute table with the retrieved raster cell value or print it. The column type
+or centroid stored in a given vector map. It can update a <b>column</b> in the linked
+vector attribute table with the retrieved raster cell value or print it. The column type
 needs to be numeric (integer, float, double, ...).
 <p>
 If the <b>-p</b> flag is used, then the attribute table is not updated
@@ -12,8 +12,11 @@
 is interpolated from the four nearest raster cells values using an inverse
 distance weighting method (IDW). This is useful for cases when the vector
 point density is much higher than the raster cell size.
+<p>
+Points and centroid with shared category number cannot be processed.
+To solved this, unique categories may be added with <em>v.category</em> in
+a separate layer.
 
-
 <h2>NOTES</h2>
 
 If multiple points have the same category, the attribute value is set to NULL.
@@ -77,6 +80,7 @@
 <h2>SEE ALSO</h2>
 
 <em>
+<a href="v.category.html">v.category</a>,
 <a href="v.db.addtable.html">v.db.addtable</a>,
 <a href="v.db.select.html">v.db.select</a>,
 <a href="v.drape.html">v.drape</a>,



More information about the grass-commit mailing list