Kaynağa Gözat

Added offset parameter to import raster maps with user defined band numbers.

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@46429 15284696-431f-4ddb-bdfa-cd5b030d7da7
Soeren Gebbert 14 yıl önce
ebeveyn
işleme
05c018e70f
2 değiştirilmiş dosya ile 56 ekleme ve 4 silme
  1. 16 4
      raster/r.in.gdal/main.c
  2. 40 0
      raster/r.in.gdal/r.in.gdal.html

+ 16 - 4
raster/r.in.gdal/main.c

@@ -63,11 +63,12 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
     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 @@ int main(int argc, char *argv[])
 
 		/* 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);
 

+ 40 - 0
raster/r.in.gdal/r.in.gdal.html

@@ -221,6 +221,46 @@ the what the map's bounds and resolution should be beforehand.
 
 <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