[GRASS-SVN] r32154 - grass-addons/gipe/i.vi
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Jul 18 03:08:52 EDT 2008
Author: ychemin
Date: 2008-07-18 03:08:52 -0400 (Fri, 18 Jul 2008)
New Revision: 32154
Added:
grass-addons/gipe/i.vi/evi.c
Modified:
grass-addons/gipe/i.vi/main.c
Log:
Added EVI
Added: grass-addons/gipe/i.vi/evi.c
===================================================================
--- grass-addons/gipe/i.vi/evi.c (rev 0)
+++ grass-addons/gipe/i.vi/evi.c 2008-07-18 07:08:52 UTC (rev 32154)
@@ -0,0 +1,24 @@
+#include<stdio.h>
+#include<math.h>
+#include<stdlib.h>
+
+//EVI: Enhanced Vegetation Index
+//Huete A.R., Liu H.Q., Batchily K., vanLeeuwen W. (1997)
+//A comparison of vegetation indices global set of TM images for EOS-MODIS
+//Remote Sensing of Environment, 59:440-451.
+
+double e_vi( double bluechan, double redchan, double nirchan )
+{
+ double tmp, result;
+
+ tmp = nirchan + 6.0*redchan - 7.5*bluechan + 1.0 ;
+
+ if( tmp == 0.0 ){
+ result = -1.0;
+ } else {
+ result = 2.5 * ( nirchan - redchan ) / tmp ;
+ }
+
+ return result;
+
+}
Modified: grass-addons/gipe/i.vi/main.c
===================================================================
--- grass-addons/gipe/i.vi/main.c 2008-07-17 23:00:26 UTC (rev 32153)
+++ grass-addons/gipe/i.vi/main.c 2008-07-18 07:08:52 UTC (rev 32154)
@@ -3,7 +3,7 @@
* MODULE: i.vi
* AUTHOR(S): Baburao Kamble baburaokamble at gmail.com
* Yann Chemin - ychemin at gmail.com
- * PURPOSE: Calculates 13 vegetation indices
+ * PURPOSE: Calculates 14 vegetation indices
* based on biophysical parameters.
*
* COPYRIGHT: (C) 2002-2006 by the GRASS Development Team
@@ -17,8 +17,10 @@
* Those can be any use by standard satellite having V and IR.
* However arvi uses red, nir and blue;
* GVI uses B,G,R,NIR, chan5 and chan 7 of landsat;
- * and GARI uses B,G,R and NIR.
+ * and GARI uses B,G,R and NIR.
*
+ * Changelog: Added EVI on 20080718 (Yann)
+ *
*****************************************************************************/
#include <stdio.h>
@@ -31,6 +33,7 @@
double nd_vi( double redchan, double nirchan );
double ip_vi( double redchan, double nirchan );
double d_vi( double redchan, double nirchan );
+double e_vi( double bluechan, double redchan, double nirchan );
double p_vi( double redchan, double nirchan );
double wd_vi( double redchan, double nirchan );
double sa_vi( double redchan, double nirchan );
@@ -83,7 +86,7 @@
module = G_define_module();
module->keywords = _("vegetation index, biophysical parameters");
- module->description = _("13 types of vegetation indices from red and nir, and only some requiring additional bands");
+ module->description = _("14 types of vegetation indices from red and nir, and only some requiring additional bands");
/* Define the different options */
input1 = G_define_option() ;
@@ -91,7 +94,7 @@
input1->type = TYPE_STRING;
input1->required = YES;
input1->gisprompt =_("Name of VI");
- input1->description=_("Name of VI: sr,ndvi,ipvi,dvi,pvi,wdvi,savi,msavi,msavi2,gemi,arvi,gvi,gari.");
+ input1->description=_("Name of VI: sr,ndvi,ipvi,dvi,evi,pvi,wdvi,savi,msavi,msavi2,gemi,arvi,gvi,gari.");
input1->answer =_("ndvi");
input2 = G_define_option() ;
@@ -257,7 +260,6 @@
DCELL d_chan7chan;
G_percent(row,nrows,2);
// printf("row = %i/%i\n",row,nrows);
- /* read soil input maps */
if(G_get_raster_row(infd_redchan,inrast_redchan,row,data_type_redchan)<0)
G_fatal_error(_("Could not read from <%s>"),redchan);
if(G_get_raster_row(infd_nirchan,inrast_nirchan,row,data_type_nirchan)<0)
@@ -390,6 +392,11 @@
d = d_vi(d_redchan,d_nirchan );
((DCELL *) outrast)[col] = d;
}
+ /*calculate evi */
+ if (!strcoll(viflag,"evi")){
+ d = e_vi(d_bluechan,d_redchan,d_nirchan );
+ ((DCELL *) outrast)[col] = d;
+ }
/*calculate pvi */
if (!strcoll(viflag,"pvi")){
d = p_vi(d_redchan,d_nirchan );
More information about the grass-commit
mailing list