[GRASS-SVN] r69187 - sandbox/moritz/r.object.geometry

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Aug 21 10:24:10 PDT 2016


Author: mlennert
Date: 2016-08-21 10:24:10 -0700 (Sun, 21 Aug 2016)
New Revision: 69187

Modified:
   sandbox/moritz/r.object.geometry/main.c
   sandbox/moritz/r.object.geometry/r.object.geometry.html
Log:
r.object.geometry: first version of man page; clean up some of the comments in the code


Modified: sandbox/moritz/r.object.geometry/main.c
===================================================================
--- sandbox/moritz/r.object.geometry/main.c	2016-08-21 16:46:35 UTC (rev 69186)
+++ sandbox/moritz/r.object.geometry/main.c	2016-08-21 17:24:10 UTC (rev 69187)
@@ -309,39 +309,14 @@
 	fprintf(out_fp, "%f%s", obj_geos[i].perimeter, sep);
 	fprintf(out_fp, "%f%s", 4 * sqrt(obj_geos[i].area) / obj_geos[i].perimeter, sep);
 	fprintf(out_fp, "%f%s", obj_geos[i].perimeter / (2 * sqrt(M_PI * obj_geos[i].area)), sep);
-	/* log 1 = 0, so avoid that: */
-	if (obj_geos[i].area == 1)
-		obj_geos[i].area += 0.000001;
-	fprintf(out_fp, "%f", 2 * log(obj_geos[i].perimeter) / log (obj_geos[i].area));
+	/* log 1 = 0, so avoid that by always adding 0.001 to the area: */
+	fprintf(out_fp, "%f", 2 * log(obj_geos[i].perimeter) / log (obj_geos[i].area + 0.001));
 	/* TODO: convert bounding box area and perimeter to (square) meters for -m flag */
 
 	
 	/* object id: i + min */
 
-	/* area */
-
-	/* perimeter */
-
-	/* compactness */
-	/* area / perimeter -> more compact objects have higher compactness value
-	 * most compact object in a grid is a square with side length r
-	 * area = r^2, perimeter = 4 * r = 4 * sqrt(area)
-	 * compactness = area / (4 * sqrt(area)) = sqrt(area) / 4
-	 * -> compactness is dependent of area size
-	 * -> normalize to square to make compactness of objects of 
-	 * different size comparable:
-	 * compactness = (area / perimeter) / (sqrt(area) / 4)
-	 * compactness = 4 * sqrt(area) / perimeter
-	 * -> compactness is in the range 0 < compactness <= 1
-	 */
-	 /*QUESTION: in v.to.db compactness is defined relative to the circle
-	  * of same area: perimeter / (2 * sqrt(PI * area))
-	  * shouldn't we keep the two comparable (even though in a grid we can
-	  * never reach 1 ?
-	  */
-
-	/* fractal dimension */
-
+	/* TODO */
 	/* smoothness */
 	/* perimeter of bounding box / perimeter -> smoother objects have a higher smoothness value
 	 * smoothness is in the range 0 < smoothness <= 1 */
@@ -350,6 +325,8 @@
 	
 	/* bounding box size */
 
+	/* variance of X and Y to approximate bounding ellipsoid */
+
 	fprintf(out_fp, "\n");
     }
     if (out_fp != stdout)

Modified: sandbox/moritz/r.object.geometry/r.object.geometry.html
===================================================================
--- sandbox/moritz/r.object.geometry/r.object.geometry.html	2016-08-21 16:46:35 UTC (rev 69186)
+++ sandbox/moritz/r.object.geometry/r.object.geometry.html	2016-08-21 17:24:10 UTC (rev 69187)
@@ -1,19 +1,49 @@
 <h2>DESCRIPTION</h2>
 
-<em>r.object.geometry</em> does ...
+<p>
+<em>r.object.geometry</em> calculates form statistics of raster objects
+in the <em>input</em> map and writes it to the <em>output</em> text file,
+with fields separated by the chosen <em>separator</em>.  Objects are defined
+ as clumps of adjacent cells with the same category value (e.g. output of 
+<a href="r.clump.html">r.clump</a> or <a href="i.segment.html">i.segment</a>).
 
+<p>
+By default, values are in pixels. If values in meters is desired, the user
+can set the <em>-m</em> flag.
 
+<p>
+Statistics currently calculated are exactly the same as in
+<a href="v.to.db.html">v.to.db</a> (except for compact_square):
+
+<ul>
+<li>area</li>
+<li>perimeter</li>
+<li>compact_square ( compactness compared to a square: 
+	compact_square = 4 * sqrt(area) / perimeter )
+<li>compact_circle ( compactness compared to a circle: 
+	compact_circle = perimeter / ( 2 * sqrt(PI * area) ) )</li>
+<li>fractal dimension ( fd = 2 * ( log(perimeter) / log(area + 1) ) )<li>
+</ul>
+
+More statistics might be added in the future.
+
 <h2>NOTES</h2>
 
 
 <h2>EXAMPLES</h2>
 
+<div class="code"><pre>
+g.region rast=soilsID
+r.object.geometry soilsID out=soils_geom
+</pre></div>
 
+
 <h2>SEE ALSO</h2>
 
 <em>
 <a href="i.segment.html">i.segment</a>,
 <a href="r.clump.html">r.clump</a>,
+<a href="v.to.db.html">v.to.db</a>,
 </em>
 
 <h2>AUTHOR</h2>



More information about the grass-commit mailing list