[GRASS-SVN] r49293 - in grass/trunk: lib/python raster/r.info
svn_grass at osgeo.org
svn_grass at osgeo.org
Sat Nov 19 06:59:58 EST 2011
Author: hamish
Date: 2011-11-19 03:59:58 -0800 (Sat, 19 Nov 2011)
New Revision: 49293
Modified:
grass/trunk/lib/python/raster.py
grass/trunk/raster/r.info/main.c
grass/trunk/raster/r.info/r.info.html
Log:
Consolidate r.info flags as a basis of further discussion. flags have been
grouped into (g) raster array definition (eval-safe), (e) extended metadata
(eval-unsafe), (r) array analysis (currently only range, but something like
compression yes|no could plausibly be put in there too). Separate -h history
flag is retained.
Modified: grass/trunk/lib/python/raster.py
===================================================================
--- grass/trunk/lib/python/raster.py 2011-11-18 19:37:23 UTC (rev 49292)
+++ grass/trunk/lib/python/raster.py 2011-11-19 11:59:58 UTC (rev 49293)
@@ -13,7 +13,7 @@
...
@endcode
-(C) 2008-2009 by the GRASS Development Team
+(C) 2008-2011 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
for details.
@@ -47,7 +47,7 @@
"Raster map <%(map)s> not found in current mapset." % { 'map' : map, 'map' : map}))
return False
-# run "r.info -rgstmpud ..." and parse output
+# run "r.info -gre ..." and parse output
def raster_info(map):
"""!Return information about a raster map (interface to
@@ -73,7 +73,7 @@
else:
return float(s)
- s = read_command('r.info', flags = 'rgstmpud', map = map)
+ s = read_command('r.info', flags = 'gre', map = map)
kv = parse_key_val(s)
for k in ['min', 'max']:
kv[k] = float_or_null(kv[k])
Modified: grass/trunk/raster/r.info/main.c
===================================================================
--- grass/trunk/raster/r.info/main.c 2011-11-18 19:37:23 UTC (rev 49292)
+++ grass/trunk/raster/r.info/main.c 2011-11-19 11:59:58 UTC (rev 49293)
@@ -7,7 +7,7 @@
*
* PURPOSE: Outputs basic information about a user-specified raster map layer.
*
-* COPYRIGHT: (C) 2005 by the GRASS Development Team
+* COPYRIGHT: (C) 2005-2011 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
@@ -60,8 +60,7 @@
struct Reclass reclass;
struct GModule *module;
struct Option *opt1;
- struct Flag *rflag, *sflag, *tflag, *gflag, *hflag, *mflag;
- struct Flag *uflag, *dflag, *timestampflag;
+ struct Flag *gflag, *rflag, *eflag, *hflag;
/* Initialize GIS Engine */
G_gisinit(argv[0]);
@@ -75,47 +74,26 @@
opt1 = G_define_standard_option(G_OPT_R_MAP);
+ gflag = G_define_flag();
+ gflag->key = 'g';
+ gflag->description = _("Print raster array information only");
+
rflag = G_define_flag();
rflag->key = 'r';
rflag->description = _("Print range only");
- sflag = G_define_flag();
- sflag->key = 's';
- sflag->description =
- _("Print raster map resolution (NS-res, EW-res) only");
+ eflag = G_define_flag();
+ eflag->key = 'e';
+ eflag->description = _("Print extended metadata information only");
- tflag = G_define_flag();
- tflag->key = 't';
- tflag->description = _("Print raster map type only");
-
- gflag = G_define_flag();
- gflag->key = 'g';
- gflag->description = _("Print map region only");
-
hflag = G_define_flag();
hflag->key = 'h';
hflag->description = _("Print raster history instead of info");
- uflag = G_define_flag();
- uflag->key = 'u';
- uflag->description = _("Print raster map data units only");
-
- dflag = G_define_flag();
- dflag->key = 'd';
- dflag->description = _("Print raster map vertical datum only");
-
- mflag = G_define_flag();
- mflag->key = 'm';
- mflag->description = _("Print map title only");
-
- timestampflag = G_define_flag();
- timestampflag->key = 'p';
- timestampflag->description =
- _("Print raster map timestamp (day.month.year hour:minute:seconds) only");
-
if (G_parser(argc, argv))
exit(EXIT_FAILURE);
+
name = G_store(opt1->answer);
if ((mapset = G_find_raster2(name, "")) == NULL)
G_fatal_error(_("Raster map <%s> not found"), name);
@@ -146,9 +124,8 @@
out = stdout;
- if (!rflag->answer && !sflag->answer && !tflag->answer &&
- !gflag->answer && !hflag->answer && !timestampflag->answer &&
- !mflag->answer && !uflag->answer && !dflag->answer) {
+ if (!gflag->answer && !rflag->answer &&
+ !eflag->answer && !hflag->answer) {
divider('+');
compose_line(out, "Layer: %-29.29s Date: %s", name,
@@ -321,30 +298,8 @@
fprintf(out, "\n");
}
- else { /* r,s,t,g,h, or m flag */
+ else { /* g,r,e, or h flags */
- if (rflag->answer) {
- if (data_type == CELL_TYPE) {
- if (2 == Rast_read_range(name, "", &crange)) {
- fprintf(out, "min=NULL\n");
- fprintf(out, "max=NULL\n");
- }
- else {
- fprintf(out, "min=%i\n", (CELL) zmin);
- fprintf(out, "max=%i\n", (CELL) zmax);
- }
- }
- else if (data_type == FCELL_TYPE) {
- fprintf(out, "min=%.7g\n", zmin);
- fprintf(out, "max=%.7g\n", zmax);
- }
- else {
- fprintf(out, "min=%.15g\n", zmin);
- fprintf(out, "max=%.15g\n", zmax);
- }
-
- }
-
if (gflag->answer) {
G_format_northing(cellhd.north, tmp1, -1);
G_format_northing(cellhd.south, tmp2, -1);
@@ -355,29 +310,47 @@
G_format_easting(cellhd.west, tmp2, -1);
fprintf(out, "east=%s\n", tmp1);
fprintf(out, "west=%s\n", tmp2);
- }
- if (sflag->answer) {
G_format_resolution(cellhd.ns_res, tmp3, cellhd.proj);
fprintf(out, "nsres=%s\n", tmp3);
G_format_resolution(cellhd.ew_res, tmp3, cellhd.proj);
fprintf(out, "ewres=%s\n", tmp3);
- }
- if (tflag->answer) {
fprintf(out, "datatype=%s\n",
(data_type == CELL_TYPE ? "CELL" :
(data_type == DCELL_TYPE ? "DCELL" :
(data_type == FCELL_TYPE ? "FCELL" : "??"))));
}
- if (mflag->answer) {
+ if (rflag->answer) {
+ if (data_type == CELL_TYPE) {
+ if (2 == Rast_read_range(name, "", &crange)) {
+ fprintf(out, "min=NULL\n");
+ fprintf(out, "max=NULL\n");
+ }
+ else {
+ fprintf(out, "min=%i\n", (CELL) zmin);
+ fprintf(out, "max=%i\n", (CELL) zmax);
+ }
+ }
+ else if (data_type == FCELL_TYPE) {
+ fprintf(out, "min=%.7g\n", zmin);
+ fprintf(out, "max=%.7g\n", zmax);
+ }
+ else {
+ fprintf(out, "min=%.15g\n", zmin);
+ fprintf(out, "max=%.15g\n", zmax);
+ }
+ }
+
+ if (eflag->answer) {
fprintf(out, "title=%s (%s)\n", cats_ok ? cats.title :
"??", hist_ok ? Rast_get_history(&hist, HIST_TITLE) : "??");
- }
- if (timestampflag->answer) {
+ fprintf(out, "units=%s\n", units ? units : "\"none\"");
+ fprintf(out, "vertical_datum=%s\n", vdatum ? vdatum : "\"none\"");
+
if (time_ok && (first_time_ok || second_time_ok)) {
G_format_timestamp(&ts, timebuff);
@@ -391,11 +364,6 @@
}
}
- if (uflag->answer)
- fprintf(out, "units=%s\n", units ? units : "(none)");
- if (dflag->answer)
- fprintf(out, "vertical_datum=%s\n", vdatum ? vdatum : "(none)");
-
if (hflag->answer) {
if (hist_ok) {
fprintf(out, "Data Source:\n");
Modified: grass/trunk/raster/r.info/r.info.html
===================================================================
--- grass/trunk/raster/r.info/r.info.html 2011-11-18 19:37:23 UTC (rev 49292)
+++ grass/trunk/raster/r.info/r.info.html 2011-11-19 11:59:58 UTC (rev 49293)
@@ -77,20 +77,27 @@
subset of the available information by passing various flags to the module:
<div class="code"><pre>
-r.info -rst slope
-min=0.000000
-max=52.520164
+GRASS> r.info -g slope
+north=4928030
+south=4913690
+east=609000
+west=589980
nsres=30
ewres=30
datatype=FCELL
-r.info -g slope
-north=4928030
-south=4913690
-east=609000
-west=589980
+GRASS> r.info -r slope
+min=0.000000
+max=52.520164
+
+GRASS> r.info -e slope
+title=slope in degrees (slope)
+units="none"
+vertical_datum="none"
+timestamp="none"
</pre></div>
+
<h2>SEE ALSO</h2>
<em><a href="g.mapsets.html">g.mapsets</a>,</em>
@@ -102,9 +109,11 @@
<em><a href="r.univar.html">r.univar</a>,</em>
<em><a href="r.what.html">r.what</a></em>
+
<h2>AUTHOR</h2>
Michael O'Shea,
<a href="http://www.cecer.army.mil/">U.S. Army Construction Engineering Research Laboratory</a>
-<p><i>Last changed: $Date$</i>
+<p>
+<i>Last changed: $Date$</i>
More information about the grass-commit
mailing list