[GRASS-SVN] r44043 - grass-addons/imagery/i.landsat.acca

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Oct 25 18:36:15 EDT 2010


Author: martinl
Date: 2010-10-25 15:36:15 -0700 (Mon, 25 Oct 2010)
New Revision: 44043

Modified:
   grass-addons/imagery/i.landsat.acca/
   grass-addons/imagery/i.landsat.acca/algorithm.c
   grass-addons/imagery/i.landsat.acca/description.html
   grass-addons/imagery/i.landsat.acca/local_proto.h
   grass-addons/imagery/i.landsat.acca/main.c
   grass-addons/imagery/i.landsat.acca/tools.c
Log:
i.landsat.acca: sync'ed with trunk



Property changes on: grass-addons/imagery/i.landsat.acca
___________________________________________________________________
Added: svn:ignore
   + OBJ.*
*.tmp.html


Modified: grass-addons/imagery/i.landsat.acca/algorithm.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/algorithm.c	2010-10-25 22:14:38 UTC (rev 44042)
+++ grass-addons/imagery/i.landsat.acca/algorithm.c	2010-10-25 22:36:15 UTC (rev 44043)
@@ -14,6 +14,7 @@
 #include <math.h>
 #include <unistd.h>
 #include <grass/gis.h>
+#include <grass/raster.h>
 #include <grass/glocale.h>
 
 #include "local_proto.h"
@@ -72,7 +73,7 @@
 
 extern int hist_n;
 
-void acca_algorithm(int verbose, Gfile * out, Gfile band[],
+void acca_algorithm(Gfile * out, Gfile band[],
 		    int single_pass, int with_shadow, int cloud_signature)
 {
     int i, count[5], hist_cold[hist_n], hist_warm[hist_n];
@@ -88,7 +89,7 @@
     }
 
     /* FIRST FILTER ... */
-    acca_first(verbose, out, band, with_shadow,
+    acca_first(out, band, with_shadow,
 	       count, hist_cold, hist_warm, signa);
     /* CATEGORIES: NO_DEFINED, WARM_CLOUD, COLD_CLOUD, NULL (= NO_CLOUD) */
 
@@ -120,31 +121,31 @@
     signa[KMEAN] = SCALE * signa[SUM_COLD] / ((double)count[COLD]);
     signa[COVER] = ((double)count[COLD]) / ((double)count[TOTAL]);
 
-    fprintf(stdout, "   PRELIMINARY SCENE ANALYSIS\n");
-    fprintf(stdout, "    Desert index:  %.2lf\n", idesert);
-    fprintf(stdout, "    Snow cover:    %.2lf %%\n", 100. * value[SNOW]);
-    fprintf(stdout, "    Cloud cover:   %.2lf %%\n", 100. * signa[COVER]);
-    fprintf(stdout, "    Temperature of clouds\n");
-    fprintf(stdout, "      Maximum: %.2lf K\n", signa[KMAX]);
-    fprintf(stdout, "      Mean (%s cloud)  : %.2lf K\n",
+    G_message(_("Preliminary scene analysis:"));
+    G_message(_("* Desert index: %.2lf"), idesert);
+    G_message(_("* Snow cover: %.2lf %%"), 100. * value[SNOW]);
+    G_message(_("* Cloud cover: %.2lf %%"), 100. * signa[COVER]);
+    G_message(_("* Temperature of clouds:"));
+    G_message(_("** Maximum: %.2lf "), signa[KMAX]);
+    G_message(_("** Mean (%s cloud)  : %.2lf K"),
 	    (review_warm ? "cold" : "all"), signa[KMEAN]);
-    fprintf(stdout, "      Minimum: %.2lf K\n", signa[KMIN]);
+    G_message(_("** Minimum: %.2lf K"), signa[KMIN]);
 
     /* WARNING: re-use of the variable 'value' with new meaning */
 
     /* step 14 */
     if (cloud_signature ||
 	(idesert <= .5 && signa[COVER] > 0.004 && signa[KMEAN] < 295.)) {
-	fprintf(stdout, "   HISTOGRAM CLOUD SIGNATURE\n");
+	G_message(_("Histogram cloud signature:"));
 
 	value[MEAN] = quantile(0.5, hist_cold) + K_BASE;
 	value[DSTD] = sqrt(moment(2, hist_cold, 1));
 	value[SKEW] = moment(3, hist_cold, 3) / pow(value[DSTD], 3);
 
-	fprintf(stdout, "      Mean temperature:   %.2lf K\n", value[MEAN]);
-	fprintf(stdout, "      Standard deviation: %.2lf\n", value[DSTD]);
-	fprintf(stdout, "      Skewness:           %.2lf\n", value[SKEW]);
-	fprintf(stdout, "      Histogram classes:  %d\n", hist_n);
+	G_message(_("* Mean temperature: %.2lf K"), value[MEAN]);
+	G_message(_("* Standard deviation: %.2lf"), value[DSTD]);
+	G_message(_("* Skewness: %.2lf"), value[SKEW]);
+	G_message(_("* Histogram classes: %d"), hist_n);
 
 	shift = value[SKEW];
 	if (shift > 1.)
@@ -156,9 +157,9 @@
 	value[KUPPER] = quantile(0.975, hist_cold) + K_BASE;
 	value[KLOWER] = quantile(0.835, hist_cold) + K_BASE;
 
-	fprintf(stdout, "      98.75 percentile:   %.2lf K\n", max);
-	fprintf(stdout, "      97.50 percentile:   %.2lf K\n", value[KUPPER]);
-	fprintf(stdout, "      83.50 percentile:   %.2lf K\n", value[KLOWER]);
+	G_message(_("* 98.75 percentile: %.2lf K"), max);
+	G_message(_("* 97.50 percentile: %.2lf K"), value[KUPPER]);
+	G_message(_("* 83.50 percentile: %.2lf K"), value[KLOWER]);
 
 	/* step 17 & 18 */
 	if (shift > 0.) {
@@ -174,21 +175,21 @@
 	    }
 	}
 
-	fprintf(stdout, "      Maximum temperature\n");
-	fprintf(stdout, "        Cold cloud: %.2lf K\n", value[KUPPER]);
-	fprintf(stdout, "        Warn cloud: %.2lf K\n", value[KLOWER]);
+	G_message(_("Maximum temperature:"));
+	G_message(_("* Cold cloud: %.2lf K"), value[KUPPER]);
+	G_message(_("* Warn cloud: %.2lf K"), value[KLOWER]);
     }
     else {
 	if (signa[KMEAN] < 295.) {
 	    /* Retained warm and cold clouds */
-	    G_message("    Scene with clouds");
+	    G_message(_("Result: Scene with clouds"));
 	    review_warm = 0;
 	    value[KUPPER] = 0.;
 	    value[KLOWER] = 0.;
 	}
 	else {
 	    /* Retained cold clouds */
-	    G_message("    Scene cloud free");
+	    G_message(_("Result: Scene cloud free"));
 	    review_warm = 1;
 	    value[KUPPER] = 0.;
 	    value[KLOWER] = 0.;
@@ -202,7 +203,7 @@
 	value[KUPPER] = 0.;
 	value[KLOWER] = 0.;
     }
-    acca_second(verbose, out, band[BAND6],
+    acca_second(out, band[BAND6],
 		review_warm, value[KUPPER], value[KLOWER]);
     /* CATEGORIES: IS_WARM_CLOUD, IS_COLD_CLOUD, IS_SHADOW, NULL (= NO_CLOUD) */
 
@@ -210,22 +211,22 @@
 }
 
 
-void acca_first(int verbose, Gfile * out, Gfile band[],
+void acca_first(Gfile *out, Gfile band[],
 		int with_shadow,
 		int count[], int cold[], int warm[], double stats[])
 {
     int i, row, col, nrows, ncols;
 
     char code;
-    double pixel[5], nsdi, rat56, rat45;
+    double pixel[5], nsdi, rat56;
 
     /* Creation of output file */
     out->rast = G_allocate_raster_buf(CELL_TYPE);
-    if ((out->fd = G_open_raster_new(out->name, CELL_TYPE)) < 0)
+    if ((out->fd = G_open_new(out->name, CELL_TYPE)) < 0)
 	G_fatal_error(_("Unable to create raster map <%s>"), out->name);
 
     /* ----- ----- */
-    G_message(_("Processing first pass ..."));
+    G_message(_("Processing first pass..."));
 
     stats[SUM_COLD] = 0.;
     stats[SUM_WARM] = 0.;
@@ -236,6 +237,7 @@
     ncols = G_window_cols();
 
     for (row = 0; row < nrows; row++) {
+	G_percent(row, nrows, 2);
 	for (i = BAND2; i <= BAND6; i++) {
 	    if (G_get_d_raster_row(band[i].fd, band[i].rast, row) < 0)
 		G_fatal_error(_("Unable to read raster map <%s> row %d"),
@@ -350,10 +352,9 @@
 	if (G_put_raster_row(out->fd, out->rast, CELL_TYPE) < 0)
 	    G_fatal_error(_("Failed writing raster map <%s> row %d"),
 			  out->name, row);
-
-	G_percent(row, nrows, 2);
     }
-
+    G_percent(1, 1, 1);
+    
     G_free(out->rast);
     G_close_cell(out->fd);
 
@@ -361,12 +362,12 @@
 }
 
 
-void acca_second(int verbose, Gfile * out, Gfile band,
+void acca_second(Gfile * out, Gfile band,
 		 int review_warm, double upper, double lower)
 {
     int row, col, nrows, ncols;
     char *mapset;
-
+    
     int code;
     double temp;
     Gfile tmp;
@@ -375,35 +376,35 @@
     mapset = G_find_cell2(out->name, "");
     if (mapset == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), out->name);
+    if ((out->fd = G_open_cell_old(out->name, "")) < 0)
+	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
+    
     out->rast = G_allocate_raster_buf(CELL_TYPE);
-    if ((out->fd = G_open_cell_old(out->name, mapset)) < 0)
-	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
-
+    
     /* Open to write */
     sprintf(tmp.name, "_%d.BBB", getpid());
     tmp.rast = G_allocate_raster_buf(CELL_TYPE);
-    if ((tmp.fd = G_open_raster_new(tmp.name, CELL_TYPE)) < 0)
+    if ((tmp.fd = G_open_new(tmp.name, CELL_TYPE)) < 0)
 	G_fatal_error(_("Unable to create raster map <%s>"), tmp.name);
 
     if (upper == 0.)
-	G_message(_("Removing ambiguous pixels ..."));
+	G_message(_("Removing ambiguous pixels..."));
     else
-	G_message(_("Pass two processing ..."));
+	G_message(_("Pass two processing..."));
 
     nrows = G_window_rows();
     ncols = G_window_cols();
 
     for (row = 0; row < nrows; row++) {
-	if (verbose) {
-	    G_percent(row, nrows, 2);
-	}
+	G_percent(row, nrows, 2);
+	
 	if (G_get_d_raster_row(band.fd, band.rast, row) < 0)
 	    G_fatal_error(_("Unable to read raster map <%s> row %d"),
 			  band.name, row);
 	if (G_get_c_raster_row(out->fd, out->rast, row) < 0)
 	    G_fatal_error(_("Unable to read raster map <%s> row %d"),
 			  out->name, row);
-
+	
 	for (col = 0; col < ncols; col++) {
 	    if (G_is_c_null_value((void *)((CELL *) out->rast + col))) {
 		G_set_c_null_value((CELL *) tmp.rast + col, 1);
@@ -438,9 +439,8 @@
 	    G_fatal_error(_("Cannot write to raster map <%s>"), tmp.name);
 	}
     }
-
-    /* Finalización */
-
+    G_percent(1, 1, 1);
+    
     G_free(tmp.rast);
     G_close_cell(tmp.fd);
 

Modified: grass-addons/imagery/i.landsat.acca/description.html
===================================================================
--- grass-addons/imagery/i.landsat.acca/description.html	2010-10-25 22:14:38 UTC (rev 44042)
+++ grass-addons/imagery/i.landsat.acca/description.html	2010-10-25 22:36:15 UTC (rev 44043)
@@ -1,65 +1,61 @@
-<H2>DESCRIPTION</H2>
+<h2>DESCRIPTION</h2>
 
-<EM>i.landsat.acca</EM> implements the Automated Cloud-Cover Assessment
-(ACCA) Algorithm from Irish (2000) with the constant values for pass filter
-one from Irish et al. (2006). To do this, it needs Landsat band numbers 2, 3,
-4, 5, and 6 (or band 61 for Landsat-7 ETM+) which have already been
-processed from DN into reflectance and band-6 temperature (for example with
-<em>i.landsat.toar</em>).
+<em>i.landsat.acca</em> implements the <b>Automated Cloud-Cover
+Assessment</B> (ACCA) Algorithm from Irish (2000) with the constant
+values for pass filter one from Irish et al. (2006). To do this, it
+needs Landsat band numbers 2, 3, 4, 5, and 6 (or band 61 for Landsat-7
+ETM+) which have already been processed from DN into reflectance and
+band-6 temperature
+with <em><a href="i.landsat.toar.html">i.landsat.toar</a></em>).
 
 <p>
-The ACCA algorithm gives good results over most of the planet with the exception of
-ice sheets because ACCA operates on the premise that clouds are colder than
-the land surface they cover. The algorithm was designed for Landsat-7 ETM+
-but because reflectance is used it is also useful for Landsat-4/5 TM.
+The ACCA algorithm gives good results over most of the planet with the
+exception of ice sheets because ACCA operates on the premise that
+clouds are colder than the land surface they cover. The algorithm was
+designed for Landsat-7 ETM+ but because reflectance is used it is also
+useful for Landsat-4/5 TM.
 
+<h2>NOTES</h2>
 
-<H2>NOTES</H2>
-
 <em>i.landsat.acca</em> works in the current region settings.
 
+<h2>EXAMPLES</h2>
 
-<H2>EXAMPLES</H2>
+Run the standard ACCA algorithm with filling of small cloud holes
+(the <b>-f</b> flag): With per-band reflectance raster maps
+named <tt>226_62.toar.1, 226_62.toar.2, </tt> [...] and LANDSAT-7
+thermal band <tt>226_62.toar.61</tt>, outputing to a new raster map
+named <tt>226_62.acca</tt>:
 
-Run the standard ACCA algorithm with filling of small cloud holes (the <b>-f</b> flag):
-<p>
-With per-band reflectance raster maps named <tt>226_62.toar.1,
-226_62.toar.2, </tt> [...] and LANDSAT-7 thermal band <tt>226_62.toar.61</tt>,
-outputing to a new raster map named <tt>226_62.acca</tt>:
-
 <div class="code"><pre>
-i.landsat.toar sensor=7 gain=HHHLHLHHL date=2003-04-07 product_date=2008-11-27 band_prefix=226_62 solar_elevation=49.51654
-i.landsat.acca -f band_prefix=226_62.toar output=226_62.acca
+    i.landsat.toar sensor=7 gain=HHHLHLHHL date=2003-04-07 product_date=2008-11-27 band_prefix=226_62 solar_elevation=49.51654
+    i.landsat.acca -f band_prefix=226_62.toar output=226_62.acca
 </pre></div>
 
 
-<H2>REFERENCES</H2>
-<ol>
-    <li>Irish R.R., Barker J.L., Goward S.N., and Arvidson T., 2006.
-        Characterization of the Landsat-7 ETM+ Automated Cloud-Cover
-        Assessment (ACCA) Algorithm. Photogrammetric Engineering and Remote
-        Sensing vol. 72(10): 1179-1188.</li>
+<h2>REFERENCES</h2>
 
-    <li>Irish, R.R., 2000. Landsat 7 Automatic Cloud Cover Assessment. In
-        S.S. Shen and M.R. Descour (Eds.): Algorithms for Multispectral,
-        Hyperspectral, and Ultraspectral Imagery VI. Proceedings of SPIE,
-        4049: 348-355.</li>
+<ol>
+  <li>Irish R.R., Barker J.L., Goward S.N., and Arvidson T., 2006.
+    Characterization of the Landsat-7 ETM+ Automated Cloud-Cover
+    Assessment (ACCA) Algorithm. Photogrammetric Engineering and Remote
+    Sensing vol. 72(10): 1179-1188.</li>
+  
+  <li>Irish, R.R., 2000. Landsat 7 Automatic Cloud Cover Assessment. In
+    S.S. Shen and M.R. Descour (Eds.): Algorithms for Multispectral,
+    Hyperspectral, and Ultraspectral Imagery VI. Proceedings of SPIE,
+    4049: 348-355.</li>
 </ol>
 
-
 <H2>SEE ALSO</H2>
 
 <em>
-<A HREF="i.landsat.toar.html">i.landsat.toar</A><br>
+  <a href="i.landsat.toar.html">i.landsat.toar</a>
 </em>
 
+<h2>AUTHOR</h2>
 
+E. Jorge Tizado  (ej.tizado unileon es), Dept. Biodiversity and Environmental Management, University of León, Spain
 
-<H2>AUTHOR</H2>
-
-E. Jorge Tizado  (ej.tizado unileon es)<br>
-Dept. Biodiversity and Environmental Management,
-University of León, Spain<BR>
-
 <p>
 <i>Last changed: $Date$</i>

Modified: grass-addons/imagery/i.landsat.acca/local_proto.h
===================================================================
--- grass-addons/imagery/i.landsat.acca/local_proto.h	2010-10-25 22:14:38 UTC (rev 44042)
+++ grass-addons/imagery/i.landsat.acca/local_proto.h	2010-10-25 22:36:15 UTC (rev 44043)
@@ -23,18 +23,18 @@
 {
     int fd;
     void *rast;
-    char name[1024];
+    char name[GNAME_MAX];
 
 } Gfile;
 
 
-void acca_algorithm(int, Gfile *, Gfile[], int, int, int);
-void acca_first(int, Gfile *, Gfile[], int, int[], int[], int[], double[]);
-void acca_second(int, Gfile *, Gfile, int, double, double);
+void acca_algorithm(Gfile *, Gfile[], int, int, int);
+void acca_first(Gfile *, Gfile[], int, int[], int[], int[], double[]);
+void acca_second(Gfile *, Gfile, int, double, double);
 
 int shadow_algorithm(double[]);
 
-void filter_holes(int, Gfile *);
+void filter_holes(Gfile *);
 
 void hist_put(double t, int hist[]);
 double quantile(double q, int hist[]);

Modified: grass-addons/imagery/i.landsat.acca/main.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/main.c	2010-10-25 22:14:38 UTC (rev 44042)
+++ grass-addons/imagery/i.landsat.acca/main.c	2010-10-25 22:36:15 UTC (rev 44043)
@@ -6,8 +6,9 @@
  * AUTHOR(S):    E. Jorge Tizado - ej.tizado at unileon.es
  *
  * PURPOSE:      Landsat TM/ETM+ Automatic Cloud Cover Assessment
+ *               Adopted for GRASS 7 by Martin Landa <landa.martin gmail.com>
  *
- * COPYRIGHT:    (C) 2008 by the GRASS Development Team
+ * COPYRIGHT:    (C) 2008, 2010 by the GRASS Development Team
  *
  *               This program is free software under the GNU General Public
  *   	    	 License (>=v2). Read the file COPYING that comes with GRASS
@@ -48,24 +49,17 @@
  *----------------------------------------------*/
 int check_raster(char *raster_name)
 {
-    struct Cell_head cellhd;
     RASTER_MAP_TYPE map_type;
     int raster_fd;
     char *mapset;
-
+    
     mapset = G_find_cell2(raster_name, "");
-    if (mapset == NULL) {
-	G_warning(_("Raster map <%s> not found"), raster_name);
-	return -1;
-    }
-    if (G_legal_filename(raster_name) < 0) {
-	G_warning(_("<%s> is an illegal file name"), raster_name);
-	return -1;
-    }
-    if ((raster_fd = G_open_cell_old(raster_name, mapset)) < 0) {
-	G_warning(_("Unable to open raster map <%s>"), raster_name);
-	return -1;
-    }
+    if (mapset == NULL)
+	G_fatal_error(_("Raster map <%s> not found"), raster_name);
+    
+    if ((raster_fd = G_open_cell_old(raster_name, "")) < 0)
+	G_fatal_error(_("Unable to open raster map <%s>"), raster_name);
+    
     /* Uncomment to work in full raster map
        if (G_get_cellhd(raster_name, mapset, &cellhd) < 0) {
        G_warning(_("Unable to read header of raster map <%s>"), raster_name);
@@ -76,10 +70,10 @@
        return -1;
        }
      */
-    if ((map_type = G_raster_map_type(raster_name, mapset)) != DCELL_TYPE) {
-	G_warning(_("Map is not DCELL type (process DN to radiance first)"));
-	return -1;
-    }
+    if ((map_type = G_raster_map_type(raster_name, mapset)) != DCELL_TYPE)
+	G_fatal_error(_("Input raster map <%s> is not floating point "
+			"(process DN using i.landsat.toar to radiance first)"), raster_name);
+    
     return raster_fd;
 }
 
@@ -93,31 +87,32 @@
     struct History history;
     struct GModule *module;
 
-    int i, verbose = 1;
-    struct Option *input, *output, *hist, *b56c, *b45r;
+    int i;
+    struct Option *band_prefix, *output, *hist, *b56c, *b45r;
     struct Flag *shadow, *filter, *sat5, *pass2, *csig;
     char *in_name, *out_name;
     struct Categories cats;
-    char title[RECORD_LEN];
 
     Gfile band[5], out;
 
+    char title[1024];
+    
     /* initialize GIS environment */
     G_gisinit(argv[0]);
 
     /* initialize module */
     module = G_define_module();
     module->description =
-	_("Landsat TM/ETM+ Automatic Cloud Cover Assessment (ACCA)");
-
-    input = G_define_option();
-    input->key = "band_prefix";
-    input->type = TYPE_STRING;
-    input->required = YES;
-    input->gisprompt = "input,cell,raster";
-    input->description =
-	_("Base name of the landsat band rasters ([band_prefix].[band_number])");
-
+	_("Landsat TM/ETM+ Automatic Cloud Cover Assessment (ACCA).");
+    module->keywords = _("imagery, landsat, acca");
+    
+    band_prefix = G_define_option();
+    band_prefix->key = "band_prefix";
+    band_prefix->label = _("Base name of input raster bands");
+    band_prefix->description = _("Example: 'B.' for B.1, B.2, ...");
+    band_prefix->type = TYPE_STRING;
+    band_prefix->required = YES;
+    
     output = G_define_standard_option(G_OPT_R_OUTPUT);
 
     b56c = G_define_option();
@@ -141,11 +136,12 @@
     hist->description =
 	_("Number of classes in the cloud temperature histogram");
     hist->answer = "100";
-
+    hist->guisection = _("Cloud settings");
+    
     sat5 = G_define_flag();
     sat5->key = '5';
     sat5->label = _("Data is Landsat-5 TM");
-    sat5->description = _("(i.e. thermal band is '.6' not '.61')");
+    sat5->description = _("I.e. Thermal band is '.6' not '.61')");
 
     filter = G_define_flag();
     filter->key = 'f';
@@ -155,15 +151,18 @@
     csig = G_define_flag();
     csig->key = 'x';
     csig->description = _("Always use cloud signature (step 14)");
+    csig->guisection = _("Cloud settings");
 
     pass2 = G_define_flag();
     pass2->key = '2';
     pass2->description =
 	_("Bypass second-pass processing, and merge warm (not ambiguous) and cold clouds");
+    pass2->guisection = _("Cloud settings");
 
     shadow = G_define_flag();
     shadow->key = 's';
     shadow->description = _("Include a category for cloud shadows");
+    shadow->guisection = _("Cloud settings");
 
     if (G_parser(argc, argv))
 	exit(EXIT_FAILURE);
@@ -174,31 +173,29 @@
     if (hist_n < 10)
 	hist_n = 10;
 
-    in_name = input->answer;
+    in_name = band_prefix->answer;
 
     for (i = BAND2; i <= BAND6; i++) {
-	snprintf(band[i].name, 127, "%s.%d%c", in_name, i + 2,
+	sprintf(band[i].name, "%s%d%c", in_name, i + 2,
 		 (i == BAND6 && !sat5->answer ? '1' : '\0'));
-	if ((band[i].fd = check_raster(band[i].name)) < 0) {
-	    G_fatal_error(_("Error in map name <%s>!"), band[i].name);
-	}
+	band[i].fd = check_raster(band[i].name);
 	band[i].rast = G_allocate_raster_buf(DCELL_TYPE);
     }
 
     out_name = output->answer;
 
-    snprintf(out.name, 127, "%s", out_name);
+    sprintf(out.name, "%s", out_name);
     if (G_legal_filename(out_name) < 0)
 	G_fatal_error(_("<%s> is an illegal file name"), out.name);
 
     /* --------------------------------------- */
     th_4 = atof(b56c->answer);
     th_7 = atof(b45r->answer);
-    acca_algorithm(verbose, &out, band, pass2->answer, shadow->answer,
+    acca_algorithm(&out, band, pass2->answer, shadow->answer,
 		   csig->answer);
 
     if (filter->answer)
-	filter_holes(verbose, &out);
+	filter_holes(&out);
     /* --------------------------------------- */
 
     for (i = BAND2; i <= BAND6; i++) {
@@ -210,15 +207,13 @@
     G_init_cats((CELL) 0, "", &cats);
     sprintf(title, "LANDSAT-%s Automatic Cloud Cover Assessment",
 	    sat5->answer ? "5 TM" : "7 ETM+");
-    G_set_raster_cats_title(title, &cats);
+    G_set_cats_title(title, &cats);
 
     G_set_cat(IS_SHADOW, "Shadow", &cats);
     G_set_cat(IS_COLD_CLOUD, "Cold cloud", &cats);
     G_set_cat(IS_WARM_CLOUD, "Warm cloud", &cats);
-
-    if (G_write_cats(out.name, &cats) <= 0)
-	G_warning(_("Cannot write category file for raster map <%s>"),
-		  out.name);
+    
+    G_write_cats(out.name, &cats);
     G_free_cats(&cats);
 
     /* write out command line opts */

Modified: grass-addons/imagery/i.landsat.acca/tools.c
===================================================================
--- grass-addons/imagery/i.landsat.acca/tools.c	2010-10-25 22:14:38 UTC (rev 44042)
+++ grass-addons/imagery/i.landsat.acca/tools.c	2010-10-25 22:36:15 UTC (rev 44043)
@@ -105,11 +105,11 @@
 	return (int)((CELL *) rast)[i];
 }
 
-void filter_holes(int verbose, Gfile * out)
+void filter_holes(Gfile * out)
 {
     int row, col, nrows, ncols;
     char *mapset;
-
+    
     void *arast, *brast, *crast;
     int i, pixel[9], cold, warm, shadow, nulo, lim;
 
@@ -125,11 +125,13 @@
     mapset = G_find_cell2(out->name, "");
     if (mapset == NULL)
 	G_fatal_error(_("Raster map <%s> not found"), out->name);
+    
+    if ((out->fd = G_open_cell_old(out->name, "")) < 0)
+	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
+    
     arast = G_allocate_raster_buf(CELL_TYPE);
     brast = G_allocate_raster_buf(CELL_TYPE);
     crast = G_allocate_raster_buf(CELL_TYPE);
-    if ((out->fd = G_open_cell_old(out->name, mapset)) < 0)
-	G_fatal_error(_("Unable to open raster map <%s>"), out->name);
 
     /* Open to write */
     sprintf(tmp.name, "_%d.BBB", getpid());
@@ -151,10 +153,9 @@
 		G_fatal_error(_("Unable to read raster map <%s> row %d"),
 			      out->name, row - 1);
 	}
-	if (G_get_c_raster_row(out->fd, brast, row) < 0) {
+	if (G_get_c_raster_row(out->fd, brast, row) < 0)
 	    G_fatal_error(_("Unable to read raster map <%s> row %d"),
 			  out->name, row);
-	}
 	if (row != (nrows - 1)) {
 	    if (G_get_c_raster_row(out->fd, crast, row + 1) < 0)
 		G_fatal_error(_("Unable to read raster map <%s> row %d"),
@@ -287,7 +288,6 @@
 	if (G_put_raster_row(tmp.fd, tmp.rast, CELL_TYPE) < 0)
 	    G_fatal_error(_("Failed writing raster map <%s> row %d"),
 			  tmp.name, row);
-
 	G_percent(row, nrows, 2);
     }
 



More information about the grass-commit mailing list