[GRASS-SVN] r34122 - in grass/trunk/imagery: i.modis.qc i.vi
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Oct 31 04:33:13 EDT 2008
Author: ychemin
Date: 2008-10-31 04:33:13 -0400 (Fri, 31 Oct 2008)
New Revision: 34122
Modified:
grass/trunk/imagery/i.modis.qc/main.c
grass/trunk/imagery/i.vi/main.c
Log:
i.vi: check for input files against VIname; i.modis.qc: Updated descriptions
Modified: grass/trunk/imagery/i.modis.qc/main.c
===================================================================
--- grass/trunk/imagery/i.modis.qc/main.c 2008-10-31 03:46:22 UTC (rev 34121)
+++ grass/trunk/imagery/i.modis.qc/main.c 2008-10-31 08:33:13 UTC (rev 34122)
@@ -49,10 +49,6 @@
struct History history; /*metadata */
struct Colors colors; /*Color rules */
-
-
- /************************************/
- /* FMEO Declarations**************** */
char *result; /*output raster name */
/*File Descriptors */
@@ -78,7 +74,12 @@
input1->required = YES;
input1->gisprompt = _("Name of QC type to extract");
input1->description = _("Name of QC");
- input1->options = "adjcorr,atcorr,cloud,data_quality,diff_orbit_from_500m,modland_qa_bits";
+ input1->descriptions =_("adjcorr;Adjacency Correction;"
+ "atcorr;Atmospheric Correction;"
+ "cloud;Cloud State;"
+ "data_quality;Band-Wise Data Quality Flag;"
+ "diff_orbit_from_500m;250m Band is at Different Orbit than 500m;"
+ "modland_qa_bits;MODIS Land General Quality Assessment;");
input1->answer = _("modland_qa_bits");
input2 = G_define_standard_option(G_OPT_R_INPUT);
@@ -92,6 +93,13 @@
input_band->gisprompt = "old,value";
input_band->description =
_("Band number of Modis product 250m=[1,2],500m=[1-7]");
+ input_band->descriptions =_("1;250m/500m Band 1: Red;"
+ "2;250m/500m Band 2: NIR;"
+ "3;500m Band 3: Blue;"
+ "4;500m Band 4: Green;"
+ "5;500m Band 5: SWIR 1;"
+ "6;500m Band 6: SWIR 2;"
+ "7;500m Band 7: SWIR 3;");
output = G_define_standard_option(G_OPT_R_OUTPUT);
output->key = _("output");
@@ -117,7 +125,7 @@
if ((!strcmp(qcflag, "cloud") && flag1->answer) ||
(!strcmp(qcflag, "diff_orbit_from_500m") && flag1->answer))
- G_fatal_error(_("Those flags cannot work with MOD09A @ 500m products"));
+ G_fatal_error(_("This flag is not available for MOD09A @ 500m products"));
if (!strcmp(qcflag, "data_quality")) {
if (bandno < 1 || bandno > 7)
Modified: grass/trunk/imagery/i.vi/main.c
===================================================================
--- grass/trunk/imagery/i.vi/main.c 2008-10-31 03:46:22 UTC (rev 34121)
+++ grass/trunk/imagery/i.vi/main.c 2008-10-31 08:33:13 UTC (rev 34122)
@@ -21,6 +21,7 @@
* and GARI uses B,G,R and NIR.
*
* Changelog: Added EVI on 20080718 (Yann)
+ * Added VARI on 20081014 (Yann)
*
*****************************************************************************/
@@ -46,6 +47,7 @@
double nirchan, double chan5chan, double chan7chan);
double ga_ri(double redchan, double nirchan, double bluechan,
double greenchan);
+double va_ri(double redchan, double greenchan, double bluechan);
int main(int argc, char *argv[])
{
@@ -58,9 +60,7 @@
struct History history; /*metadata */
struct Colors colors; /*Color rules */
- /* FMEO Declarations */
char *result; /*output raster name */
- /* File Descriptors */
int infd_redchan, infd_nirchan, infd_greenchan;
int infd_bluechan, infd_chan5chan, infd_chan7chan;
int outfd;
@@ -75,8 +75,8 @@
module->keywords = _("imagery, vegetation index, biophysical parameters");
module->label =
_("Calculates different types of vegetation indices.");
- module->description = _("Uses red and nir, "
- "and only some requiring additional bands.");
+ module->description = _("Uses red and nir bands mostly, "
+ "and some indices require additional bands.");
/* Define the different options */
input1 = G_define_option();
@@ -84,21 +84,21 @@
input1->type = TYPE_STRING;
input1->required = YES;
input1->description = _("Name of vegetation index");
- input1->descriptions =_("sr;Simple Ratio;"
- "ndvi;Normalized Difference Vegetation Index;"
- "ipvi;Infrared Percentage Vegetation Index;"
+ input1->descriptions =_("arvi;Atmospherically Resistant Vegetation Indices;"
"dvi;Difference Vegetation Index;"
"evi;Enhanced Vegetation Index;"
+ "gvi;Green Vegetation Index;"
+ "gari;Green atmospherically resistant vegetation index;"
+ "gemi;Global Environmental Monitoring Index;"
+ "ipvi;Infrared Percentage Vegetation Index;"
+ "msavi;Modified Soil Adjusted Vegetation Index;"
+ "msavi2;second Modified Soil Adjusted Vegetation Index;"
+ "ndvi;Normalized Difference Vegetation Index;"
"pvi;Perpendicular Vegetation Index;"
- "wdvi;Weighted Difference Vegetation Index;"
"savi;Soil Adjusted Vegetation Index;"
- "msavi;Modified Soil Adjusted Vegetation Index;"
- "msavi2;second Modified Soil Adjusted Vegetation Index;"
- "gemi;Global Environmental Monitoring Index;"
- "arvi;Atmospherically Resistant Vegetation Indices;"
- "gvi;Green Vegetation Index;"
- "gari;Green atmospherically resistant vegetation index;");
- input1->answer = "ndvi";
+ "sr;Simple Ratio;"
+ "vari;Visible Atmospherically Resistant Index;"
+ "wdvi;Weighted Difference Vegetation Index;");
input2 = G_define_standard_option(G_OPT_R_INPUT);
input2->key = "red";
@@ -108,6 +108,7 @@
input3 = G_define_standard_option(G_OPT_R_INPUT);
input3->key = "nir";
+ input3->required = NO;
input3->label =
_("Name of the nir channel surface reflectance map");
input3->description = _("Range: [0.0;1.0]");
@@ -154,13 +155,66 @@
chan7chan = input7->answer;
result = output->answer;
+ if (!strcmp(viflag, "sr") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("sr index requires red and nir maps"));
+
+ if (!strcmp(viflag, "ndvi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("ndvi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "ipvi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("ipvi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "dvi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("dvi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "pvi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("pvi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "wdvi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("wdvi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "savi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("savi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "msavi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("msavi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "msavi2") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("msavi2 index requires red and nir maps"));
+
+ if (!strcmp(viflag, "gemi") && (!(input2->answer) || !(input3->answer)) )
+ G_fatal_error(_("gemi index requires red and nir maps"));
+
+ if (!strcmp(viflag, "arvi") && (!(input2->answer) || !(input3->answer)
+ || !(input5->answer)) )
+ G_fatal_error(_("arvi index requires blue, red and nir maps"));
+
+ if (!strcmp(viflag, "evi") && (!(input2->answer) || !(input3->answer)
+ || !(input5->answer)) )
+ G_fatal_error(_("evi index requires blue, red and nir maps"));
+
+ if (!strcmp(viflag, "vari") && (!(input2->answer) || !(input4->answer)
+ || !(input5->answer)) )
+ G_fatal_error(_("vari index requires blue, green and red maps"));
+
+ if (!strcmp(viflag, "gari") && (!(input2->answer) || !(input3->answer)
+ || !(input4->answer) || !(input5->answer)) )
+ G_fatal_error(_("gari index requires blue, green, red and nir maps"));
+
+ if (!strcmp(viflag, "gvi") && (!(input2->answer) || !(input3->answer)
+ || !(input4->answer) || !(input5->answer)
+ || !(input6->answer) || !(input7->answer)) )
+ G_fatal_error(_("gvi index requires blue, green, red, nir, chan5 and chan7 maps"));
+
if ((infd_redchan = G_open_cell_old(redchan, "")) < 0)
G_fatal_error(_("Unable to open raster map <%s>"), redchan);
inrast_redchan = G_allocate_d_raster_buf();
- if ((infd_nirchan = G_open_cell_old(nirchan, "")) < 0)
- G_fatal_error(_("Unable to open raster map <%s>"), nirchan);
- inrast_nirchan = G_allocate_d_raster_buf();
+ if (nirchan) {
+ if ((infd_nirchan = G_open_cell_old(nirchan, "")) < 0)
+ G_fatal_error(_("Unable to open raster map <%s>"), nirchan);
+ inrast_nirchan = G_allocate_d_raster_buf();
+ }
if (greenchan) {
if ((infd_greenchan = G_open_cell_old(greenchan, "")) < 0)
@@ -209,9 +263,11 @@
if (G_get_d_raster_row(infd_redchan, inrast_redchan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
redchan, row);
- if (G_get_d_raster_row(infd_nirchan, inrast_nirchan, row) < 0)
- G_fatal_error(_("Unable to read raster map <%s> row %d"),
- nirchan, row);
+ if (nirchan) {
+ if (G_get_d_raster_row(infd_nirchan, inrast_nirchan, row) < 0)
+ G_fatal_error(_("Unable to read raster map <%s> row %d"),
+ nirchan, row);
+ }
if (greenchan) {
if (G_get_d_raster_row(infd_greenchan, inrast_greenchan, row) < 0)
G_fatal_error(_("Unable to read raster map <%s> row %d"),
@@ -237,14 +293,19 @@
for (col = 0; col < ncols; col++)
{
d_redchan = inrast_redchan[col];
+ if(nirchan)
d_nirchan = inrast_nirchan[col];
+ if(greenchan)
d_greenchan = inrast_greenchan[col];
+ if(bluechan)
d_bluechan = inrast_bluechan[col];
+ if(chan5chan)
d_chan5chan = inrast_chan5chan[col];
+ if(chan7chan)
d_chan7chan = inrast_chan7chan[col];
if (G_is_d_null_value(&d_redchan) ||
- G_is_d_null_value(&d_nirchan) ||
+ ((nirchan) && G_is_d_null_value(&d_nirchan)) ||
((greenchan) && G_is_d_null_value(&d_greenchan)) ||
((bluechan) && G_is_d_null_value(&d_bluechan)) ||
((chan5chan) && G_is_d_null_value(&d_chan5chan)) ||
@@ -300,6 +361,9 @@
if (!strcmp(viflag, "gari"))
outrast[col] = ga_ri(d_redchan, d_nirchan, d_bluechan, d_greenchan);
+
+ if (!strcmp(viflag, "vari"))
+ outrast[col] = va_ri(d_redchan, d_greenchan, d_bluechan);
}
}
if (G_put_d_raster_row(outfd, outrast) < 0)
More information about the grass-commit
mailing list