[GRASS-SVN] r46429 - grass/trunk/raster/r.in.gdal

svn_grass at osgeo.org svn_grass at osgeo.org
Fri May 27 11:49:38 EDT 2011


Author: huhabla
Date: 2011-05-27 08:49:38 -0700 (Fri, 27 May 2011)
New Revision: 46429

Modified:
   grass/trunk/raster/r.in.gdal/main.c
   grass/trunk/raster/r.in.gdal/r.in.gdal.html
Log:
Added offset parameter to import raster maps with user defined band numbers.

Modified: grass/trunk/raster/r.in.gdal/main.c
===================================================================
--- grass/trunk/raster/r.in.gdal/main.c	2011-05-27 07:32:52 UTC (rev 46428)
+++ grass/trunk/raster/r.in.gdal/main.c	2011-05-27 15:49:38 UTC (rev 46429)
@@ -63,11 +63,12 @@
     char error_msg[8096];
     int projcomp_error = 0;
     int overwrite;
+    int offset = 0;
 
     struct GModule *module;
     struct
     {
-	struct Option *input, *output, *target, *title, *outloc, *band, *memory;
+	struct Option *input, *output, *target, *title, *outloc, *band, *memory, *offset;
     } parm;
     struct Flag *flag_o, *flag_e, *flag_k, *flag_f, *flag_l, *flag_c;
 
@@ -118,6 +119,14 @@
     parm.title->description = _("Title for resultant raster map");
     parm.title->guisection = _("Metadata");
 
+    parm.offset = G_define_option();
+    parm.offset->key = "offset";
+    parm.offset->type = TYPE_INTEGER;
+    parm.offset->required = NO;
+    parm.offset->answer = "0";
+    parm.offset->description = _("The offset will be added to the band number while output raster map name creation");
+    parm.offset->guisection = _("Metadata");
+    
     parm.outloc = G_define_option();
     parm.outloc->key = "location";
     parm.outloc->type = TYPE_STRING;
@@ -167,6 +176,9 @@
     input = parm.input->answer;
 
     output = parm.output->answer;
+    
+    offset = atoi(parm.offset->answer);
+    
     if ((title = parm.title->answer))
 	G_strip(title);
 
@@ -502,21 +514,21 @@
 
 		/* check: two channels with identical name ? */
 		if (strcmp(colornamebuf, colornamebuf2) == 0)
-		    sprintf(colornamebuf, "%d", nBand);
+		    sprintf(colornamebuf, "%d", nBand + offset);
 		else
 		    strcpy(colornamebuf2, colornamebuf);
 
 		/* avoid bad color names; in case of 'Gray' often all channels are named 'Gray' */
 		if (strcmp(colornamebuf, "Undefined") == 0 ||
 		    strcmp(colornamebuf, "Gray") == 0)
-		    sprintf(szBandName, "%s.%d", output, nBand);
+		    sprintf(szBandName, "%s.%d", output, nBand + offset);
 		else {
 		    G_tolcase(colornamebuf);
 		    sprintf(szBandName, "%s.%s", output, colornamebuf);
 		}
 	    }
 	    else
-		sprintf(szBandName, "%s.%d", output, nBand);
+		sprintf(szBandName, "%s.%d", output, nBand + offset);
 
 	    ImportBand(hBand, szBandName, &ref);
 

Modified: grass/trunk/raster/r.in.gdal/r.in.gdal.html
===================================================================
--- grass/trunk/raster/r.in.gdal/r.in.gdal.html	2011-05-27 07:32:52 UTC (rev 46428)
+++ grass/trunk/raster/r.in.gdal/r.in.gdal.html	2011-05-27 15:49:38 UTC (rev 46429)
@@ -221,6 +221,46 @@
 
 <h2>EXAMPLES</h2>
 
+<h3>ECAD Data</h3>
+
+The <a href="http://eca.knmi.nl/">European Climate Assessment and Dataset (ECAD) project</a> 
+provides climate data for europe ranging from 1950 - 2010. To import the different 
+chunks of data provided by the project as netCDF files, the offset parameter can be used to get 
+daily numbered raster maps from 1. Jan. 1950 on. Make sure you are in a LatLong location.
+
+<div class="code"><pre>
+# Import precipitation data
+r.in.gdal -o input=rr_0.25deg_reg_1950-1964_v4.0.nc output=precipitation offset=0
+r.in.gdal -o input=rr_0.25deg_reg_1965-1979_v4.0.nc output=precipitation offset=5479
+r.in.gdal -o input=rr_0.25deg_reg_1980-1994_v4.0.nc output=precipitation offset=10957
+r.in.gdal -o input=rr_0.25deg_reg_1995-2010_v4.0.nc output=precipitation offset=16436
+
+# Import air pressure data
+r.in.gdal -o input=pp_0.25deg_reg_1950-1964_v4.0.nc output=air_pressure offset=0
+r.in.gdal -o input=pp_0.25deg_reg_1965-1979_v4.0.nc output=air_pressure offset=5479
+r.in.gdal -o input=pp_0.25deg_reg_1980-1994_v4.0.nc output=air_pressure offset=10957
+r.in.gdal -o input=pp_0.25deg_reg_1995-2010_v4.0.nc output=air_pressure offset=16436
+
+# Import min temperature data
+r.in.gdal -o input=tn_0.25deg_reg_1950-1964_v4.0.nc output=temperatur_min offset=0
+r.in.gdal -o input=tn_0.25deg_reg_1965-1979_v4.0.nc output=temperatur_min offset=5479
+r.in.gdal -o input=tn_0.25deg_reg_1980-1994_v4.0.nc output=temperatur_min offset=10957
+r.in.gdal -o input=tn_0.25deg_reg_1995-2010_v4.0.nc output=temperatur_min offset=16436
+
+# Import max temperature data
+r.in.gdal -o input=tx_0.25deg_reg_1950-1964_v4.0.nc output=temperatur_max offset=0
+r.in.gdal -o input=tx_0.25deg_reg_1965-1979_v4.0.nc output=temperatur_max offset=5479
+r.in.gdal -o input=tx_0.25deg_reg_1980-1994_v4.0.nc output=temperatur_max offset=10957
+r.in.gdal -o input=tx_0.25deg_reg_1995-2010_v4.0.nc output=temperatur_max offset=16436
+
+# Import mean temperature data
+r.in.gdal -o input=tg_0.25deg_reg_1950-1964_v4.0.nc output=temperatur_mean offset=0
+r.in.gdal -o input=tg_0.25deg_reg_1965-1979_v4.0.nc output=temperatur_mean offset=5479
+r.in.gdal -o input=tg_0.25deg_reg_1980-1994_v4.0.nc output=temperatur_mean offset=10957
+r.in.gdal -o input=tg_0.25deg_reg_1995-2010_v4.0.nc output=temperatur_mean offset=16436
+</pre></div>
+
+
 <h3>GTOPO30 DEM</h3>
 
 To avoid that the GTOPO30 data are read incorrectly, you can add a new line



More information about the grass-commit mailing list