[GRASS-SVN] r59084 - in grass/trunk/raster/r.li: r.li.cwed r.li.dominance r.li.edgedensity r.li.mpa r.li.mps r.li.padcv r.li.padrange r.li.padsd r.li.patchdensity r.li.patchnum r.li.pielou r.li.renyi r.li.richness r.li.shannon r.li.shape r.li.simpson

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Feb 18 06:06:08 PST 2014


Author: mmetz
Date: 2014-02-18 06:06:07 -0800 (Tue, 18 Feb 2014)
New Revision: 59084

Modified:
   grass/trunk/raster/r.li/r.li.cwed/cwed.c
   grass/trunk/raster/r.li/r.li.dominance/dominance.c
   grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
   grass/trunk/raster/r.li/r.li.mpa/mpa.c
   grass/trunk/raster/r.li/r.li.mps/mps.c
   grass/trunk/raster/r.li/r.li.mps/r.li.mps.html
   grass/trunk/raster/r.li/r.li.padcv/padcv.c
   grass/trunk/raster/r.li/r.li.padrange/padrange.c
   grass/trunk/raster/r.li/r.li.padsd/padsd.c
   grass/trunk/raster/r.li/r.li.patchdensity/main.c
   grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html
   grass/trunk/raster/r.li/r.li.patchnum/main.c
   grass/trunk/raster/r.li/r.li.pielou/pielou.c
   grass/trunk/raster/r.li/r.li.renyi/renyi.c
   grass/trunk/raster/r.li/r.li.richness/r.li.richness.html
   grass/trunk/raster/r.li/r.li.richness/richness.c
   grass/trunk/raster/r.li/r.li.shannon/shannon.c
   grass/trunk/raster/r.li/r.li.shape/main.c
   grass/trunk/raster/r.li/r.li.simpson/simpson.c
Log:
r.li: modules work in current region

Modified: grass/trunk/raster/r.li/r.li.cwed/cwed.c
===================================================================
--- grass/trunk/raster/r.li/r.li.cwed/cwed.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.cwed/cwed.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -348,7 +348,7 @@
 	Rast_set_c_null_value(&corrCell, 1);
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf_corr[i + ad->x];
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 	    if (!(Rast_is_null_value(&corrCell, CELL_TYPE))) {
@@ -479,7 +479,7 @@
 	Rast_set_d_null_value(&corrCell, 1);
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf_corr[i + ad->x];
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 	    if (!(Rast_is_null_value(&corrCell, DCELL_TYPE))) {
@@ -610,7 +610,7 @@
 	Rast_set_f_null_value(&corrCell, 1);
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf_corr[i + ad->x];
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 	    if (!(Rast_is_null_value(&corrCell, FCELL_TYPE))) {

Modified: grass/trunk/raster/r.li/r.li.dominance/dominance.c
===================================================================
--- grass/trunk/raster/r.li/r.li.dominance/dominance.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.dominance/dominance.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -152,7 +152,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -339,7 +339,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -526,7 +526,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c
===================================================================
--- grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.edgedensity/edgedensity.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -168,8 +168,8 @@
 	    mask_sup[i + ad->x] = 0;
 	}
 
-	if (read(mask_fd, mask_inf, (ad->cl * sizeof(int))) <= 0) {
-	    G_fatal_error("reading mask_corr");
+	if (read(mask_fd, mask_inf, (ad->cl * sizeof(int))) < 0) {
+	    G_fatal_error("reading mask_inf at first row");
 	    return RLI_ERRORE;
 	}
 
@@ -211,8 +211,8 @@
 	    mask_inf = mask_tmp;
 
 	    if ((j + 1) < ad->rl) {	/* not last row */
-		if (read(mask_fd, mask_inf, (ad->cl * sizeof(int))) <= 0) {
-		    G_fatal_error("reading mask_inf");
+		if (read(mask_fd, mask_inf, (ad->cl * sizeof(int))) < 0) {
+		    G_fatal_error("reading mask_inf at row j");
 		    return RLI_ERRORE;
 		}
 	    }
@@ -231,7 +231,7 @@
 	for (i = 0; i < ad->cl; i++) {
 	    corrCell = buf_corr[i + ad->x];
 
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -239,17 +239,17 @@
 		area++;
 		if ((i + 1) == ad->cl)	/*last cell of the row */
 		    Rast_set_c_null_value(&nextCell, 1);
-		else if (masked && mask_corr[i + 1 + ad->x] == 0)
+		else if (masked && mask_corr[i + 1] == 0)
 		    Rast_set_c_null_value(&nextCell, 1);
 		else
 		    nextCell = buf_corr[i + 1 + ad->x];
 
-		if (masked && mask_sup[i + ad->x] == 0)
+		if (masked && mask_sup[i] == 0)
 		    Rast_set_c_null_value(&supCell, 1);
 		else
 		    supCell = buf_sup[i + ad->x];
 
-		if (masked && mask_inf[i + ad->x] == 0)
+		if (masked && mask_inf[i] == 0)
 		    Rast_set_c_null_value(&infCell, 1);
 		else
 		    infCell = buf_inf[i + ad->x];
@@ -490,7 +490,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf_corr[i + ad->x];
 
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -498,17 +498,17 @@
 		area++;
 		if ((i + 1) == ad->cl)	/*last cell of the row */
 		    Rast_set_d_null_value(&nextCell, 1);
-		else if (masked && mask_corr[i + 1 + ad->x] == 0)
+		else if (masked && mask_corr[i + 1] == 0)
 		    Rast_set_d_null_value(&nextCell, 1);
 		else
 		    nextCell = buf_corr[i + 1 + ad->x];
 
-		if (masked && mask_sup[i + ad->x] == 0)
+		if (masked && mask_sup[i] == 0)
 		    Rast_set_d_null_value(&supCell, 1);
 		else
 		    supCell = buf_sup[i + ad->x];
 
-		if (masked && mask_inf[i + ad->x] == 0)
+		if (masked && mask_inf[i] == 0)
 		    Rast_set_d_null_value(&infCell, 1);
 		else
 		    infCell = buf_inf[i + ad->x];
@@ -746,7 +746,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf_corr[i + ad->x];
 
-	    if (masked && mask_corr[i + ad->x] == 0) {
+	    if (masked && mask_corr[i] == 0) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -754,17 +754,17 @@
 		area++;
 		if ((i + 1) == ad->cl)	/*last cell of the row */
 		    Rast_set_f_null_value(&nextCell, 1);
-		else if (masked && mask_corr[i + 1 + ad->x] == 0)
+		else if (masked && mask_corr[i + 1] == 0)
 		    Rast_set_f_null_value(&nextCell, 1);
 		else
 		    nextCell = buf_corr[i + 1 + ad->x];
 
-		if (masked && mask_sup[i + ad->x] == 0)
+		if (masked && mask_sup[i] == 0)
 		    Rast_set_f_null_value(&supCell, 1);
 		else
 		    supCell = buf_sup[i + ad->x];
 
-		if (masked && mask_inf[i + ad->x] == 0)
+		if (masked && mask_inf[i] == 0)
 		    Rast_set_f_null_value(&infCell, 1);
 		else
 		    infCell = buf_inf[i + ad->x];

Modified: grass/trunk/raster/r.li/r.li.mpa/mpa.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mpa/mpa.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.mpa/mpa.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -133,7 +133,7 @@
 	}
 
 	for (i = 0; i < ad->cl; i++) {
-	    if (masked && mask_buf[i + ad->x] == 0) {
+	    if (masked && mask_buf[i] == 0) {
 		Rast_set_c_null_value(&buf[i + ad->x], 1);
 	    }
 	    if (!(Rast_is_c_null_value(&buf[i + ad->x]))) {
@@ -193,7 +193,7 @@
 	}
 
 	for (i = 0; i < ad->cl; i++) {
-	    if (masked && mask_buf[i + ad->x] == 0) {
+	    if (masked && mask_buf[i] == 0) {
 		Rast_set_d_null_value(&buf[i + ad->x], 1);
 	    }
 	    if (!(Rast_is_d_null_value(&buf[i + ad->x]))) {
@@ -252,7 +252,7 @@
 	}
 
 	for (i = 0; i < ad->cl; i++) {
-	    if (masked && mask_buf[i + ad->x] == 0) {
+	    if (masked && mask_buf[i] == 0) {
 		Rast_set_f_null_value(&buf[i + ad->x], 1);
 	    }
 	    if (!(Rast_is_f_null_value(&buf[i + ad->x]))) {

Modified: grass/trunk/raster/r.li/r.li.mps/mps.c
===================================================================
--- grass/trunk/raster/r.li/r.li.mps/mps.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.mps/mps.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -120,7 +120,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -202,7 +202,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -215,7 +215,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -343,7 +343,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -425,7 +425,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -438,7 +438,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -566,7 +566,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -648,7 +648,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -661,7 +661,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.mps/r.li.mps.html
===================================================================
--- grass/trunk/raster/r.li/r.li.mps/r.li.mps.html	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.mps/r.li.mps.html	2014-02-18 14:06:07 UTC (rev 59084)
@@ -2,7 +2,12 @@
 
 <em>r.li.mps</em> (mean patch size) calculates the mean size of the 
 patches in the sampling area as:<br>
+<!--
 <img src="rlimps_formula.png" alt="rliMps formula"><br>
+-->
+<div class="code"><pre>
+MPS = A / Npatch
+</pre></div>
 
 with:
 <ul>

Modified: grass/trunk/raster/r.li/r.li.padcv/padcv.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padcv/padcv.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.padcv/padcv.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -121,7 +121,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -203,7 +203,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -216,7 +216,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -364,7 +364,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -446,7 +446,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -459,7 +459,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -607,7 +607,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -689,7 +689,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -702,7 +702,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.padrange/padrange.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padrange/padrange.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.padrange/padrange.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -121,7 +121,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -203,7 +203,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -216,7 +216,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -321,7 +321,7 @@
 		area_p = cell_size_m * pst[old_pid].count / 10000;
 		if (min > area_p)
 		    min = area_p;
-		if (max > area_p)
+		if (max < area_p)
 		    max = area_p;
 	    }
 	}
@@ -357,7 +357,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -439,7 +439,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -452,7 +452,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -531,12 +531,9 @@
 
     if (npatch > 0) {
 	double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
-	double area_units;
 	double area_p;
 	double cell_size_m;
-	double mps;
-	double psd;
-	double diff;
+	double min, max;
 
 	/* calculate distance */
 	G_begin_distance_calculations();
@@ -551,22 +548,20 @@
 
 	cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) *
 	              (((NS_DIST1 + NS_DIST2) / 2) / hd.rows);
-	area_units = cell_size_m * area;
 
-	/* mean patch size in hectares */
-	mps = area_units / (npatch * 10000);
-
-	/* calculate patch size standard deviation */
-	psd = 0;
+	/* get min and max patch size */
+	min = 1.0 / 0.0;	/* inf */
+	max = -1.0 / 0.0;	/* -inf */
 	for (old_pid = 1; old_pid <= pid; old_pid++) {
 	    if (pst[old_pid].count > 0) {
 		area_p = cell_size_m * pst[old_pid].count / 10000;
-		diff = area_p - mps;
-		psd += diff * diff;
+		if (min > area_p)
+		    min = area_p;
+		if (max < area_p)
+		    max = area_p;
 	    }
 	}
-	psd = sqrt(psd / npatch);
-	*result = psd;
+	*result = max - min;
     }
     else
 	Rast_set_d_null_value(result, 1);
@@ -598,7 +593,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -680,7 +675,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -693,7 +688,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 
@@ -772,12 +767,9 @@
 
     if (npatch > 0) {
 	double EW_DIST1, EW_DIST2, NS_DIST1, NS_DIST2;
-	double area_units;
 	double area_p;
 	double cell_size_m;
-	double mps;
-	double psd;
-	double diff;
+	double min, max;
 
 	/* calculate distance */
 	G_begin_distance_calculations();
@@ -792,22 +784,20 @@
 
 	cell_size_m = (((EW_DIST1 + EW_DIST2) / 2) / hd.cols) *
 	              (((NS_DIST1 + NS_DIST2) / 2) / hd.rows);
-	area_units = cell_size_m * area;
 
-	/* mean patch size in hectares */
-	mps = area_units / (npatch * 10000);
-
-	/* calculate patch size standard deviation */
-	psd = 0;
+	/* get min and max patch size */
+	min = 1.0 / 0.0;	/* inf */
+	max = -1.0 / 0.0;	/* -inf */
 	for (old_pid = 1; old_pid <= pid; old_pid++) {
 	    if (pst[old_pid].count > 0) {
 		area_p = cell_size_m * pst[old_pid].count / 10000;
-		diff = area_p - mps;
-		psd += diff * diff;
+		if (min > area_p)
+		    min = area_p;
+		if (max < area_p)
+		    max = area_p;
 	    }
 	}
-	psd = sqrt(psd / npatch);
-	*result = psd;
+	*result = max - min;
     }
     else
 	Rast_set_d_null_value(result, 1);

Modified: grass/trunk/raster/r.li/r.li.padsd/padsd.c
===================================================================
--- grass/trunk/raster/r.li/r.li.padsd/padsd.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.padsd/padsd.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -120,7 +120,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -202,7 +202,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -215,7 +215,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -361,7 +361,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -443,7 +443,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -456,7 +456,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -602,7 +602,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -684,7 +684,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -697,7 +697,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.patchdensity/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/main.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.patchdensity/main.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -121,7 +121,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -203,7 +203,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -216,7 +216,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -344,7 +344,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -426,7 +426,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -439,7 +439,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -567,7 +567,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -649,7 +649,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -662,7 +662,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html
===================================================================
--- grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.patchdensity/r.li.patchdensity.html	2014-02-18 14:06:07 UTC (rev 59084)
@@ -3,7 +3,7 @@
 <em>r.li.patchdensity</em> calculates the "patch density index", 
 the number of patches per square kilometer, as:
 <div class="code"><pre>
-PD = (Npatch / A) * 1000000
+PD = Npatch / A
 </pre></div>
 
 with:

Modified: grass/trunk/raster/r.li/r.li.patchnum/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.patchnum/main.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.patchnum/main.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -120,7 +120,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_c_buf();
     Rast_set_c_null_value(buf_null, Rast_window_cols());
@@ -202,7 +202,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -215,7 +215,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_c_null_value(&supCell, 1);
 	    }
 
@@ -321,7 +321,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_d_buf();
     Rast_set_d_null_value(buf_null, Rast_window_cols());
@@ -403,7 +403,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -416,7 +416,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_d_null_value(&supCell, 1);
 	    }
 
@@ -522,7 +522,7 @@
     int mask_fd, *mask_buf, *mask_sup, *mask_tmp, masked;
     struct Cell_head hd;
 
-    Rast_get_cellhd(ad->raster, "", &hd);
+    Rast_get_window(&hd);
 
     buf_null = Rast_allocate_f_buf();
     Rast_set_f_null_value(buf_null, Rast_window_cols());
@@ -604,7 +604,7 @@
 	    pid_corr[j + ad->x] = 0;
 	    
 	    corrCell = buf[j + ad->x];
-	    if (masked && (mask_buf[j + ad->x] == 0)) {
+	    if (masked && (mask_buf[j] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
@@ -617,7 +617,7 @@
 	    area++;
 	    
 	    supCell = buf_sup[j + ad->x];
-	    if (masked && (mask_sup[j + ad->x] == 0)) {
+	    if (masked && (mask_sup[j] == 0)) {
 		Rast_set_f_null_value(&supCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.pielou/pielou.c
===================================================================
--- grass/trunk/raster/r.li/r.li.pielou/pielou.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.pielou/pielou.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -152,7 +152,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -339,7 +339,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -526,7 +526,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.renyi/renyi.c
===================================================================
--- grass/trunk/raster/r.li/r.li.renyi/renyi.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.renyi/renyi.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -175,7 +175,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -364,7 +364,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -553,7 +553,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.richness/r.li.richness.html
===================================================================
--- grass/trunk/raster/r.li/r.li.richness/r.li.richness.html	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.richness/r.li.richness.html	2014-02-18 14:06:07 UTC (rev 59084)
@@ -19,12 +19,7 @@
 <p>
 <!-- TODO: verify next: -->
 If the input raster map contains only NULL values then <em>r.li.richness</em>
-returns -1.<br>
-If you want to change these -1 values to NULL, run subsequently on the resulting map:
-<div class="code"><pre>
-r.null setnull=-1 input=my_map
-</pre></div>
-after index calculation.
+returns 0.<br>
 
 
 <h2>EXAMPLES</h2>

Modified: grass/trunk/raster/r.li/r.li.richness/richness.c
===================================================================
--- grass/trunk/raster/r.li/r.li.richness/richness.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.richness/richness.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -23,9 +23,9 @@
 #include "../r.li.daemon/avl.h"
 #include "../r.li.daemon/daemon.h"
 
-double calculate(struct area_entry *ad, int fd, double *result);
-double calculateD(struct area_entry *ad, int fd, double *result);
-double calculateF(struct area_entry *ad, int fd, double *result);
+double calculate(int fd, struct area_entry *ad, double *result);
+double calculateD(int fd, struct area_entry *ad, double *result);
+double calculateF(int fd, struct area_entry *ad, double *result);
 
 int main(int argc, char *argv[])
 {
@@ -70,17 +70,17 @@
     switch (ad->data_type) {
     case CELL_TYPE:
 	{
-	    ris = calculate(ad, fd, &indice);
+	    ris = calculate(fd, ad, &indice);
 	    break;
 	}
     case DCELL_TYPE:
 	{
-	    ris = calculateD(ad, fd, &indice);
+	    ris = calculateD(fd, ad, &indice);
 	    break;
 	}
     case FCELL_TYPE:
 	{
-	    ris = calculateF(ad, fd, &indice);
+	    ris = calculateF(fd, ad, &indice);
 	    break;
 	}
     default:
@@ -102,7 +102,7 @@
 
 
 
-double calculate(struct area_entry *ad, int fd, double *result)
+double calculate(int fd, struct area_entry *ad, double *result)
 {
     CELL *buf;
     CELL corrCell;
@@ -112,17 +112,10 @@
     int mask_fd = -1, *mask_buf = NULL;
     int ris = 0;
     int masked = FALSE;
-    int a = 0;			/* a=0 if all cells are null */
-
     long m = 0;
-
-    double indice = 0;
-
     avl_tree albero = NULL;
-
     generic_cell uc;
 
-
     uc.t = CELL_TYPE;
 
     /* open mask if needed */
@@ -150,13 +143,15 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
 	    if (!(Rast_is_null_value(&corrCell, uc.t))) {
-		a = 1;
-		if (corrCell != precCell) {
+
+		if (!(Rast_is_null_value(&precCell, uc.t)) &&
+		     corrCell != precCell) {
+
 		    if (albero == NULL) {
 			uc.val.c = precCell;
 			albero = avl_make(uc, (long)1);
@@ -193,10 +188,6 @@
 			}
 		    }
 		}		/* endif not equal cells */
-		else {		/*equal cells */
-
-		    ;
-		}
 	    }
 	    precCell = corrCell;
 	}
@@ -240,22 +231,17 @@
 	}
     }
 
-    if (a != 0) {
-	indice = m;
-    }
-    else			/*if a is 0, that is all cell are null, i put index=-1 */
-	indice = (double)(-1);
+    *result = m;
 
+    avl_destroy(albero);
     if (masked)
 	G_free(mask_buf);
 
-    *result = indice;
-
     return RLI_OK;
 }
 
 
-double calculateD(struct area_entry *ad, int fd, double *result)
+double calculateD(int fd, struct area_entry *ad, double *result)
 {
     DCELL *buf;
     DCELL corrCell;
@@ -265,14 +251,8 @@
     int mask_fd = -1, *mask_buf = NULL;
     int ris = 0;
     int masked = FALSE;
-    int a = 0;			/* a=0 if all cells are null */
-
     long m = 0;
-
-    double indice = 0;
-
     avl_tree albero = NULL;
-
     generic_cell uc;
 
     uc.t = DCELL_TYPE;
@@ -303,14 +283,15 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each dcell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if (masked && mask_buf[i + ad->x] == 0) {
+	    if (masked && mask_buf[i] == 0) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
 	    if (!(Rast_is_null_value(&corrCell, uc.t))) {
-		a = 1;
 
-		if (corrCell != precCell) {
+		if (!(Rast_is_null_value(&precCell, uc.t)) &&
+		     corrCell != precCell) {
+
 		    if (albero == NULL) {
 			uc.val.dc = precCell;
 			albero = avl_make(uc, (long)1);
@@ -347,10 +328,6 @@
 		    }
 
 		}		/* endif not equal dcells */
-		else {		/*equal dcells */
-
-		    ;
-		}
 	    }
 	    precCell = corrCell;
 	}
@@ -394,24 +371,18 @@
 	}
     }
 
+    *result = m;
 
-    if (a != 0) {		/*if a is 0, that is all cell are null, i put index=-1 */
-	indice = m;
-    }
-    else
-	indice = (double)(-1);
-
-
+    avl_destroy(albero);
     if (masked)
 	G_free(mask_buf);
 
-    *result = indice;
     return RLI_OK;
 }
 
 
 
-double calculateF(struct area_entry *ad, int fd, double *result)
+double calculateF(int fd, struct area_entry *ad, double *result)
 {
     FCELL *buf;
     FCELL corrCell;
@@ -421,14 +392,8 @@
     int mask_fd = -1, *mask_buf = NULL;
     int ris = 0;
     int masked = FALSE;
-    int a = 0;			/* a=0 if all cells are null */
-
     long m = 0;
-
-    double indice = 0;
-
     avl_tree albero = NULL;
-
     generic_cell uc;
 
     uc.t = FCELL_TYPE;
@@ -460,14 +425,15 @@
 
 	    corrCell = buf[i + ad->x];
 
-	    if (masked && mask_buf[i + ad->x] == 0) {
+	    if (masked && mask_buf[i] == 0) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 
 	    if (!(Rast_is_null_value(&corrCell, uc.t))) {
-		a = 1;
 
-		if (corrCell != precCell) {
+		if (!(Rast_is_null_value(&precCell, uc.t)) &&
+		     corrCell != precCell) {
+
 		    if (albero == NULL) {
 			uc.val.fc = precCell;
 			albero = avl_make(uc, (long)1);
@@ -551,19 +517,11 @@
 	}
     }
 
+    *result = m;
 
-
-    if (a != 0) {		/*if a is 0, that is all cell are null, i put index=-1 */
-	indice = m;
-    }
-    else
-	indice = (double)(-1);
-
-
+    avl_destroy(albero);
     if (masked)
 	G_free(mask_buf);
 
-
-    *result = indice;
     return RLI_OK;
 }

Modified: grass/trunk/raster/r.li/r.li.shannon/shannon.c
===================================================================
--- grass/trunk/raster/r.li/r.li.shannon/shannon.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.shannon/shannon.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -153,7 +153,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -340,7 +340,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -527,7 +527,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 

Modified: grass/trunk/raster/r.li/r.li.shape/main.c
===================================================================
--- grass/trunk/raster/r.li/r.li.shape/main.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.shape/main.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -66,14 +66,15 @@
     int *mask_buf = NULL;
 
     Rast_set_c_null_value(&complete_value, 1);
-    Rast_get_cellhd(ad->raster, "", &hd);
 
+    Rast_get_window(&hd);
+
     /* open mask if needed */
     if (ad->mask == 1) {
 	if ((mask_fd = open(ad->mask_name, O_RDONLY, 0755)) < 0)
 	    return 0;
 
-	mask_buf = malloc(ad->cl * sizeof(int));
+	mask_buf = G_malloc(ad->cl * sizeof(int));
 
 	for (i = 0; i < ad->rl; i++) {
 	    if (read(mask_fd, mask_buf, (ad->cl * sizeof(int))) < 0)
@@ -85,7 +86,7 @@
 		}
 	    }
 	}
-	/* todo? free(mask_buf); */
+	G_free(mask_buf);
     }
 
     /* calculate distance */

Modified: grass/trunk/raster/r.li/r.li.simpson/simpson.c
===================================================================
--- grass/trunk/raster/r.li/r.li.simpson/simpson.c	2014-02-18 14:03:45 UTC (rev 59083)
+++ grass/trunk/raster/r.li/r.li.simpson/simpson.c	2014-02-18 14:06:07 UTC (rev 59084)
@@ -154,7 +154,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_c_null_value(&corrCell, 1);
 	    }
 
@@ -338,7 +338,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_d_null_value(&corrCell, 1);
 	    }
 
@@ -522,7 +522,7 @@
 	for (i = 0; i < ad->cl; i++) {	/* for each cell in the row */
 	    corrCell = buf[i + ad->x];
 
-	    if ((masked) && (mask_buf[i + ad->x] == 0)) {
+	    if ((masked) && (mask_buf[i] == 0)) {
 		Rast_set_f_null_value(&corrCell, 1);
 	    }
 



More information about the grass-commit mailing list