[GRASS-SVN] r48918 - grass/trunk/imagery/i.landsat.toar

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Oct 23 16:29:04 EDT 2011


Author: martinl
Date: 2011-10-23 13:29:04 -0700 (Sun, 23 Oct 2011)
New Revision: 48918

Modified:
   grass/trunk/imagery/i.landsat.toar/main.c
Log:
i.landsat.toar: add overwrite flag


Modified: grass/trunk/imagery/i.landsat.toar/main.c
===================================================================
--- grass/trunk/imagery/i.landsat.toar/main.c	2011-10-23 20:20:12 UTC (rev 48917)
+++ grass/trunk/imagery/i.landsat.toar/main.c	2011-10-23 20:29:04 UTC (rev 48918)
@@ -49,6 +49,7 @@
     lsat_data lsat;
     char band_in[GNAME_MAX], band_out[GNAME_MAX];
     int i, j, q, method, pixel, dn_dark[MAX_BANDS], dn_mode[MAX_BANDS];
+    int overwrite;
     double qcal, rad, ref, percent, ref_mode, sat_zenith, rayleigh;
     
     struct Colors colors;
@@ -67,7 +68,8 @@
     G_add_keyword(_("landsat"));
     G_add_keyword(_("top-of-atmosphere reflectance"));
     G_add_keyword(_("dos-type simple atmospheric correction"));
-
+    module->overwrite = TRUE;
+    
     /* It defines the different parameters */
     input_prefix = G_define_option();
     input_prefix->key = "input_prefix";
@@ -211,6 +213,8 @@
     outputname = output_prefix->answer;
     sensorname = sensor -> answer ? sensor->answer: "";
     
+    overwrite = G_check_overwrite(argc, argv);
+    
     G_zero(&lsat, sizeof(lsat));
     
     if (adate->answer != NULL) {
@@ -469,9 +473,20 @@
     for (i = 0; i < lsat.bands; i++) {
 	sprintf(band_in, "%s%d", inputname, lsat.band[i].code);
 	sprintf(band_out, "%s%d", outputname, lsat.band[i].code);
-
+	
 	if ((infd = Rast_open_old(band_in, "")) < 0)
 	    G_fatal_error(_("Unable to open raster map <%s>"), band_in);
+	
+	if (G_find_raster2(band_out, "")) {
+	    if (overwrite) {
+		G_warning(_("Raster map <%s> already exists and will be overwritten"), band_out);
+	    }
+	    else {
+		G_warning(_("Raster map <%s> exists. Skipping."), band_out);
+		continue;
+	    }
+	}
+	
 	in_data_type = Rast_get_map_type(infd);
 	Rast_get_cellhd(band_in, "", &cellhd);
 



More information about the grass-commit mailing list