[GRASS-SVN] r34816 - in grass/branches/develbranch_6:
raster/r.clump raster/r.surf.idw scripts/r.reclass.area
svn_grass at osgeo.org
svn_grass at osgeo.org
Tue Dec 9 11:43:52 EST 2008
Author: martinl
Date: 2008-12-09 11:43:52 -0500 (Tue, 09 Dec 2008)
New Revision: 34816
Modified:
grass/branches/develbranch_6/raster/r.clump/clump.c
grass/branches/develbranch_6/raster/r.clump/main.c
grass/branches/develbranch_6/raster/r.surf.idw/main.c
grass/branches/develbranch_6/scripts/r.reclass.area/r.reclass.area
Log:
message standardization
r.reclass.area: fix fully qualified input name
Modified: grass/branches/develbranch_6/raster/r.clump/clump.c
===================================================================
--- grass/branches/develbranch_6/raster/r.clump/clump.c 2008-12-09 13:29:17 UTC (rev 34815)
+++ grass/branches/develbranch_6/raster/r.clump/clump.c 2008-12-09 16:43:52 UTC (rev 34816)
@@ -18,8 +18,8 @@
#include <time.h>
#include <grass/gis.h>
+#include <grass/glocale.h>
#include "local_proto.h"
-#include <grass/glocale.h>
#define INCR 1024
@@ -95,13 +95,13 @@
/* initialize clump labels */
label = 0;
- G_message(_("CLUMP PASS %d ... "), pass);
- fflush(stderr);
+ G_message(_("Pass %d..."), pass);
for (row = 0; row < nrows; row++) {
if (G_get_map_row(in_fd, cur_in + 1, row) < 0)
- G_fatal_error(_("Unable to properly read input raster map"));
-
- G_percent(row, nrows, 2);
+ G_fatal_error(_("Unable to read raster map row %d "),
+ row);
+
+ G_percent(row+1, nrows, 2);
X = 0;
for (col = 1; col <= ncols; col++) {
LEFT = X;
@@ -235,7 +235,8 @@
G_set_null_value(&out_cell[column], 1, CELL_TYPE);
}
if (G_put_raster_row(out_fd, out_cell, CELL_TYPE) < 0)
- G_fatal_error(_("Unable to properly write output raster map"));
+ G_fatal_error(_("Failed writing raster map row %d"),
+ row);
}
/* switch the buffers so that the current buffer becomes the previous */
@@ -247,9 +248,8 @@
cur_clump = prev_clump;
prev_clump = temp_clump;
}
- G_percent(row, nrows, 2);
+
print_time(&cur_time);
-
}
return 0;
}
@@ -269,11 +269,11 @@
seconds = seconds % 60;
if (hours)
- G_message("%2d:%02d:%02d", hours, minutes, seconds);
+ G_verbose_message("%2d:%02d:%02d", hours, minutes, seconds);
else if (minutes)
- G_message("%d:%02d", minutes, seconds);
+ G_verbose_message("%d:%02d", minutes, seconds);
else
- G_message("%d seconds", seconds);
+ G_verbose_message("%d seconds", seconds);
return 0;
}
Modified: grass/branches/develbranch_6/raster/r.clump/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.clump/main.c 2008-12-09 13:29:17 UTC (rev 34815)
+++ grass/branches/develbranch_6/raster/r.clump/main.c 2008-12-09 16:43:52 UTC (rev 34816)
@@ -8,7 +8,7 @@
* PURPOSE: Recategorizes data in a raster map layer by grouping cells
* that form physically discrete areas into unique categories.
*
- * COPYRIGHT: (C) 2006 by the GRASS Development Team
+ * COPYRIGHT: (C) 2006-2008 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
@@ -19,10 +19,9 @@
#include <stdlib.h>
#include <string.h>
#include <grass/gis.h>
+#include <grass/glocale.h>
#include "local_proto.h"
-#include <grass/glocale.h>
-
int main(int argc, char *argv[])
{
struct Colors colr;
@@ -47,9 +46,9 @@
/* Define the different options */
module = G_define_module();
- module->keywords = _("raster");
+ module->keywords = _("raster, statistics, reclass");
module->description =
- _("Recategorizes data in a raster map layer by grouping cells "
+ _("Recategorizes data in a raster map by grouping cells "
"that form physically discrete areas into unique categories.");
opt1 = G_define_standard_option(G_OPT_R_INPUT);
@@ -100,7 +99,7 @@
clump(in_fd, out_fd);
- G_message(_("Creating support files..."));
+ G_debug(1, "Creating support files...");
G_close_cell(in_fd);
G_close_cell(out_fd);
@@ -110,7 +109,7 @@
if (opt3->answer != NULL)
strcpy(title, opt3->answer);
else
- sprintf(title, "clump of %s in %s", name, mapset);
+ sprintf(title, "clump of <%s@%s>", name, mapset);
G_put_cell_title(OUTPUT, title);
G_read_range(OUTPUT, G_mapset(), &range);
@@ -118,6 +117,7 @@
G_make_random_colors(&colr, min, max);
G_write_colors(OUTPUT, G_mapset(), &colr);
- G_message(_("%d clumps"), range.max);
+ G_done_msg(_("%d clumps."), range.max);
+
exit(EXIT_SUCCESS);
}
Modified: grass/branches/develbranch_6/raster/r.surf.idw/main.c
===================================================================
--- grass/branches/develbranch_6/raster/r.surf.idw/main.c 2008-12-09 13:29:17 UTC (rev 34815)
+++ grass/branches/develbranch_6/raster/r.surf.idw/main.c 2008-12-09 16:43:52 UTC (rev 34816)
@@ -13,7 +13,7 @@
* Radim Blazek <radim.blazek gmail.com>
* PURPOSE: spatial interpolation based on distance squared weighting of
* the values of nearest irregularly spaced data points
- * COPYRIGHT: (C) 1999-2007 by the GRASS Development Team
+ * COPYRIGHT: (C) 1999-2008 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
@@ -35,9 +35,9 @@
#include <stdlib.h>
#include <math.h>
#include <grass/gis.h>
+#include <grass/glocale.h>
#define MAIN
#include "main.h"
-#include <grass/glocale.h>
static int error_flag = 0;
static char *input;
@@ -66,9 +66,9 @@
G_gisinit(argv[0]);
module = G_define_module();
- module->keywords = _("raster");
+ module->keywords = _("raster, interpolation");
module->description =
- _("Surface interpolation utility for raster map layers.");
+ _("Surface interpolation utility for raster map.");
parm.input = G_define_standard_option(G_OPT_R_INPUT);
@@ -89,7 +89,7 @@
exit(EXIT_FAILURE);
if (sscanf(parm.npoints->answer, "%d", &n) != 1 || n <= 0)
- G_fatal_error(_("%s=%s - illegal value"), parm.npoints->key,
+ G_fatal_error(_("Illegal value for '%s' (%s)"), parm.npoints->key,
parm.npoints->answer);
npoints = n;
@@ -100,8 +100,7 @@
current_mapset = G_mapset();
/* Get database window parameters */
- if (G_get_window(&window) < 0)
- G_fatal_error(_("Unable to read current region parameters"));
+ G_get_window(&window);
/* Make sure layer_map is available */
layer_mapset = G_find_cell(input, "");
@@ -162,7 +161,8 @@
G_command_history(&history);
G_write_history(output, &history);
- G_done_msg("");
+ G_done_msg(" ");
+
exit(EXIT_SUCCESS);
}
@@ -230,11 +230,11 @@
nbr_head->searchptr = &(nbr_head->Mptr); /* see replace_neighbor */
#endif
- G_message(_("Interpolating raster map <%s>... %d rows... "), output,
+ G_message(_("Interpolating raster map <%s> (%d rows)... "), output,
nrows);
for (row = 0; row < nrows; row++) { /* loop over rows */
- G_percent(row, nrows, 2);
+ G_percent(row+1, nrows, 2);
/* if mask occurs, read current row of the mask */
if (mask && G_get_map_row(maskfd, mask, row) < 0)
@@ -682,12 +682,13 @@
/* enter data by allocation of individual matrix elements */
*npts = 0;
- fprintf(stderr, "Reading %s...", input);
+ G_message(_("Reading raster map <%s>..."), input);
for (row = 0, Rptr = rowlist; row < rows; row++) {
- G_percent(row, rows, 1);
+ G_percent(row+1, rows, 2);
if (G_get_map_row_nomask(fd, cell, row) < 0)
- G_fatal_error(_("Cannot read row"));
+ G_fatal_error(_("Unable to read raster map row %d"),
+ row);
for (col = 0; col < cols; col++) {
if (cell[col] != 0) {
@@ -706,7 +707,7 @@
if (Rptr->prior != Rptr) /* non-zero input data in this row */
Rptr++->y = row;
} /* loop over rows */
- G_percent(row, rows, 1);
+
endlist = Rptr; /* point to element after last valid row list dummy */
/* add final link to complete doubly-linked lists */
Modified: grass/branches/develbranch_6/scripts/r.reclass.area/r.reclass.area
===================================================================
--- grass/branches/develbranch_6/scripts/r.reclass.area/r.reclass.area 2008-12-09 13:29:17 UTC (rev 34815)
+++ grass/branches/develbranch_6/scripts/r.reclass.area/r.reclass.area 2008-12-09 16:43:52 UTC (rev 34816)
@@ -5,7 +5,7 @@
# MODULE: r.reclass.area
# AUTHOR(S): NRCS
# PURPOSE: Reclasses a raster map greater or less than user specified area size (in hectares)
-# COPYRIGHT: (C) 1999 by the GRASS Development Team
+# COPYRIGHT: (C) 1999-2008 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
@@ -20,33 +20,37 @@
# 1998 from NRCS, slightly modified for GRASS 4.2.1
#%Module
-#% description: Reclasses a raster map greater or less than user specified area size (in hectares)
+#% description: Reclasses a raster map greater or less than user specified area size (in hectares).
#% keywords: raster, statistics, aggregation
#%End
+
#%option
#% key: input
#% type: string
#% gisprompt: old,cell,raster
-#% description: raster input map
+#% description: Name of input raster map
#% required : yes
#%END
+
#%option
+#% key: output
+#% type: string
+#% gisprompt: new,cell,raster
+#% description: Name for output raster map
+#% required : yes
+#%END
+
+#%option
#% key: lesser
#% type: double
-#% description: lesser val option that sets the <= area size limit [hectares]
+#% description: Lesser value option that sets the <= area size limit [hectares]
#%END
+
#%option
#% key: greater
#% type: double
-#% description: greater val option that sets the >= area size limit [hectares]
+#% description: Greater value option that sets the >= area size limit [hectares]
#%END
-#%option
-#% key: output
-#% type: string
-#% gisprompt: new,cell,raster
-#% description: reclass raster output map
-#% required : yes
-#%END
if [ -z "$GISBASE" ] ; then
echo "You must be in GRASS GIS to run this program." >&2
@@ -70,13 +74,13 @@
LC_NUMERIC=C
export LC_NUMERIC
-infile="$GIS_OPT_INPUT"
+infile=`echo $GIS_OPT_INPUT | cut -f1 -d'@'`
outfile="$GIS_OPT_OUTPUT"
g.region -p | head -n 1 |grep 0 > /dev/null
if [ $? -eq 0 ] ; then
- g.message -e "xy-locations are not supported."
- g.message -e "Need projected data with grids in meter."
+ g.message -e "xy-locations are not supported"
+ g.message -e "Need projected data with grids in meter"
exit 1
fi
@@ -89,10 +93,9 @@
limit=$GIS_OPT_GREATER
fi
if [ -z "$GIS_OPT_GREATER" -a -z "$GIS_OPT_LESSER" ] ; then
- g "ERROR: you have to specify either lesser= or greater="
+ g.message -e "You have to specify either lesser= or greater="
exit 1
fi
-
file2="$infile.clump.$outfile"
@@ -100,7 +103,7 @@
filename="${fullname}"
BASE="${name}"
if [ "$filename" = "" ] ; then
- g.message -e "Raster map [$infile] does not exist."
+ g.message -e "Raster map <$infile> not found"
exit 1
else
infile="$filename"
@@ -110,10 +113,10 @@
filename2="${fullname}"
BASE="${name}"
if test "$filename2" ; then
- g.message -e "Temporal raster map [$filename2] exists."
+ g.message -e "Temporal raster map <$filename2> exists"
exit 1
else
- g.message "Generating a clumped raster file ..."
+ g.message "Generating a clumped raster map..."
r.clump input="$infile" output="$file2"
fi
@@ -144,11 +147,11 @@
# printf("%d = %d %.4f\n",$1,hectares,hectares)}' > "$infile.rules"
# else
if test $op = 0; then
- g.message "Generating a reclass rules file with area size less than or equal to $limit hectares"
+ g.message "Generating a reclass rules file with area size less than or equal to $limit hectares..."
r.stats -aln in=$file2,$infile fs='|' | awk -F'|' '{limit='$limit'; hectares=$5 * 0.0001;
{if (hectares <= limit) printf("%d = %d %s\n",$1,$3,$4)}}' > "$infile.rules"
else
- g.message "Generating a reclass rules file with area size greater than or equal to $limit hectares"
+ g.message "Generating a reclass rules file with area size greater than or equal to $limit hectares..."
r.stats -aln in=$file2,$infile fs='|' | awk -F'|' '{limit='$limit'; hectares=$5 * 0.0001;
{if (hectares >= limit) printf("%d = %d %s\n",$1,$3,$4)}}' > "$infile.rules"
fi
@@ -157,11 +160,12 @@
if test "$outfile" = ""; then
outfile="${infile}_${limit}"
fi
-g.message "Generating reclass raster map <$outfile>"
+g.message "Generating output raster map <$outfile>..."
cat "$infile.rules" | r.reclass i="$file2" o="$outfile.recl"
r.mapcalc "$outfile=$outfile.recl"
-g.message "Written: $outfile"
g.remove rast="$outfile.recl","$file2" --quiet
#####cleanup
rm -f "$infile.rules"
+
+exit 0
More information about the grass-commit
mailing list