[GRASS-CVS] markus: grass6/vector/v.to.db areas.c, 1.9,
1.10 description.html, 1.24, 1.25 global.h, 1.9, 1.10 main.c,
1.21, 1.22 parse.c, 1.23, 1.24 update.c, 1.20, 1.21
grass at intevation.de
grass at intevation.de
Sun Dec 2 08:01:48 EST 2007
Author: markus
Update of /grassrepository/grass6/vector/v.to.db
In directory doto:/tmp/cvs-serv9610
Modified Files:
areas.c description.html global.h main.c parse.c update.c
Log Message:
Dylan Beaudette: added polygon's Fractal Dimension D
Index: areas.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/areas.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- areas.c 23 Apr 2007 11:01:14 -0000 1.9
+++ areas.c 2 Dec 2007 13:01:46 -0000 1.10
@@ -25,10 +25,10 @@
area = 0;
perimeter = 0;
- if ((options.option == O_COMPACT) || (options.option == O_AREA)) {
+ if ((options.option == O_COMPACT) || (options.option == O_FD) || (options.option == O_AREA)) {
area = Vect_get_area_area(Map, area_num);
}
- if ((options.option == O_COMPACT) || (options.option == O_PERIMETER)) {
+ if ((options.option == O_COMPACT) || (options.option == O_FD) || (options.option == O_PERIMETER)) {
Vect_get_area_points(Map, area_num, Ppoints);
perimeter = Vect_line_geodesic_length(Ppoints);
}
@@ -47,6 +47,9 @@
break;
case O_COMPACT:
Values[idx].d1 = perimeter / (2.0 * sqrt(M_PI * area));
+ break;
+ case O_FD:
+ Values[idx].d1 = 2.0 * log(perimeter) / log(area) ;
break;
}
found = 1;
Index: description.html
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/description.html,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- description.html 19 Nov 2007 01:01:10 -0000 1.24
+++ description.html 2 Dec 2007 13:01:46 -0000 1.25
@@ -93,6 +93,25 @@
v.db.select mysoils layer=2
</pre></div>
+<p>
+Calculate polygon's Fractal Dimension D based on the formula:
+<br><tt>
+D = 2 * (log perimeter) / (log area):<br>
+</tt>
+<div class="code"><pre>
+g.copy vect=soils,mysoils
+v.db.addcol mysoils col="d double precision"
+v.to.db mysoils option=fd column="d"
+
+g.region vect=mysoils res=50
+v.to.rast in=mysoils out=soils_fd type=area use=attr column=d
+r.colors map=soils_fd color=gyr
+
+d.mon x0
+d.rast.leg soils_fd
+d.vect mysoils type=boundary
+</pre></div>
+
<h3>Printing reports</h3>
Report x,y,z coordinates of points in the input vector map:<br>
Index: global.h
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/global.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- global.h 11 Dec 2006 17:47:03 -0000 1.9
+++ global.h 2 Dec 2007 13:01:46 -0000 1.10
@@ -61,12 +61,14 @@
#define O_QUERY 6 /* Query database records linked by another field (qfield) */
#define O_SIDES 7 /* Left and right area of boundary */
#define O_COMPACT 8 /* Compactness of an area. Circle = 1.0 */
-#define O_PERIMETER 9 /* Compactness of an area. Circle = 1.0 */
+#define O_PERIMETER 9
#define O_START 10 /* line/boundary starting point */
#define O_END 11 /* line/boundary end point */
#define O_SLOPE 12 /* Line slope */
+
+#define O_FD 13 /* fractal dimension */
#define U_ACRES 1
#define U_HECTARES 2
Index: main.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/main.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- main.c 16 Nov 2007 11:02:51 -0000 1.21
+++ main.c 2 Dec 2007 13:01:46 -0000 1.22
@@ -70,7 +70,7 @@
if ( options.option == O_QUERY ){
query(&Map);
} else if ( ( options.option == O_AREA ) || ( options.option == O_COMPACT ) ||
- ( options.option == O_PERIMETER ) ){
+ ( options.option == O_PERIMETER ) || ( options.option == O_FD ) ){
read_areas(&Map);
} else {
read_lines(&Map);
Index: parse.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/parse.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- parse.c 12 Oct 2007 14:45:50 -0000 1.23
+++ parse.c 2 Dec 2007 13:01:46 -0000 1.24
@@ -47,13 +47,15 @@
parms.option->type = TYPE_STRING;
parms.option->required = YES;
parms.option->multiple = NO;
- parms.option->options = "cat,area,compact,perimeter,length,count,coor,start,end,sides,query,slope";
+ parms.option->options = "cat,area,compact,fd,perimeter,length,count,coor,start,end,sides,query,slope";
parms.option->description = _("Value to upload");
parms.option->descriptions =
"cat;insert new row for each category if doesn't exist yet;"
"area;area size;"
- "compact;compactness of an area, calculated as \n"
+ "compact;compactness of an area, calculated as \n"
" compactness = perimeter / (2 * sqrt(PI * area));"
+ "fd;fractal dimension of an area, calculated as \n"
+ " fd = 2 * (log(perimeter) / log(area));"
"perimeter;perimeter length of an area;"
"length;line length;"
"count;number of features for each category;"
@@ -135,7 +137,7 @@
if (!options.print) {
if ( options.option == O_AREA || options.option == O_LENGTH || options.option == O_COUNT
- || options.option == O_QUERY || options.option == O_COMPACT
+ || options.option == O_QUERY || options.option == O_COMPACT || options.option == O_FD
|| options.option == O_PERIMETER || options.option == O_SLOPE ) /* one column required */
{
if ( ncols != 1) {
@@ -191,6 +193,7 @@
else if (strcmp (s, "sides") == 0) x = O_SIDES;
else if (strcmp (s, "query") == 0) x = O_QUERY;
else if (strcmp (s, "compact") == 0) x = O_COMPACT;
+ else if (strcmp (s, "fd") == 0) x = O_FD;
else if (strcmp (s, "perimeter") == 0) x = O_PERIMETER;
else if (strcmp (s, "slope") == 0) x = O_SLOPE;
Index: update.c
===================================================================
RCS file: /grassrepository/grass6/vector/v.to.db/update.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- update.c 19 Sep 2007 21:19:12 -0000 1.20
+++ update.c 2 Dec 2007 13:01:46 -0000 1.21
@@ -47,6 +47,7 @@
case O_AREA:
case O_QUERY:
case O_COMPACT:
+ case O_FD:
case O_PERIMETER:
case O_SLOPE:
sprintf (buf1, "update %s set %s =", Fi->table, options.col[0]);
@@ -78,6 +79,7 @@
case O_LENGTH:
case O_AREA:
case O_COMPACT:
+ case O_FD:
case O_PERIMETER:
case O_SLOPE:
sprintf (buf2, "%s %f where %s = %d", buf1, Values[i].d1, Fi->key, Values[i].cat);
More information about the grass-commit
mailing list