<html><body><div style="color:#000; background-color:#fff; font-family:arial, helvetica, sans-serif;font-size:10pt"><div><br></div><div>Hi,</div><div><br></div><div>I have been trying to get some results from GRASS for a couple of weeks now but am hitting a wall. What I am trying to do is to take an area of land from a series of Landsat 7 ETM+ images and calculate NDVI over the area for the purpose of comparison over a time-period. This obviously requires atmospheric correction, so the command sequence I am using after importing the images for a given mapset is:<br></div><div><br></div><div># Generate radiance values<br>i.landsat.toar input_prefix="B" output_prefix="R" metfile="./L71174038_03820080324/L71174038_03820080324_MTL.txt" sensor="tm7"<br><br># Atmospheric correction<br>i.tasscap -7 band1=R1 band2=R2 band3=R3 band4=R4 band5=R5 band7=R7 outprefix=TC<br>i.landsat.dehaze band1=R1 band2=R2 band3=R3 band4=R4 band5=R5 band7=R7
tasscap4=TC.4 outprefix=D<br><br># Generate NDVI map<br>r.mapcalc 'ndvi=if((D.3 == 0 && D.4 == 0), -1, (D.4 - D.3) / (D.4 + D.3))'<br></div><div><br></div><div>Then I mask the NDVI map with an area raster which I already created. There is probably a better way of doing this.<br></div><div><br># Mask NDVI map with individual regions<br>r.mapcalc 'area_ndvi = ndvi * area_mask@PERMANENT'<br></div><div><br></div><div>Finally I want an average value of the NDVI over the area. There is definitely a better way of doing this but I couldn't find a grass command that spits out a single value. Instead I used r.stats to give the area of each group of values and then wrote a Perl script to average these.<br></div><div><br># Process statistics<br>r.stats -a --q area_ndvi | ./stats.pl<br></div><div><br></div><div>Ok, so here come the questions:</div><div><br></div><div>1) Is there a better way to simply get an average of all values over a
given area to replace my stats.pl script?</div><div><br></div><div>2) and this is the big one. When I perform i.landsat.dehaze I get rasters with primarily negative values. This renders the NDVI calculation meaningless as they are ratios of +ve and -ve values. I am presuming this is a mistake as negative reflectance has little meaning anyway - did I use the wrong sequence of commands? Below are info outputs for the red-band after the TOAR and dehaze operations respectively:</div><div><br></div><div>Many thanks for any help on this,</div><div>Jamie</div><div><br></div><div> +----------------------------------------------------------------------------+<br> | Layer: R3 Date: Wed May 2 20:15:30 2012 |<br> |
Mapset: L71174038_03820080324 Login of Creator: jamie |<br> | Location: area |<br> | DataBase: /home/jamie/grassdata |<br> | Title: ( R3
) |<br> | Timestamp: none
|<br> |----------------------------------------------------------------------------|<br> | |<br> | Type of Map: raster Number of Categories: 255 |<br> | Data Type:
DCELL |<br> | Rows: 6961 |<br> | Columns:
7911 |<br> | Total Cells: 55068471 |<br> | Projection: UTM (zone
36) |<br> | N: 3619200 S: 3410370 Res: 30 |<br> | E: 843630 W: 606300 Res: 30 |<br> | Range of data: min =
-0.0129146013370688 max = 0.605436510681785 |<br> | |<br> | Data Description: |<br> | generated by
i.landsat.toar |<br> | |<br> |
Comments: |<br> | Reflectance of Landsat-7 ETM+ (method uncorrected) |<br> | ---------------------------------------------------------------- |<br> | Acquisition date ...................... 2008-03-24
|<br> | Production date ....................... 2012-02-23 |<br> | |<br> | Earth-sun distance (d) ................ 0.99699779 |<br> | Digital number (DN) range ............. 1 to
255 |<br> | Calibration constants (Lmin to Lmax) .. -5.000 to +234.400 |<br> | DN to Radiance (gain and bias) ........ +0.94252 and -5.94252 |<br> | Mean solar irradiance (ESUN) .......... 1551.000 |<br> | Reflectance = Radiance divided by ..... 387.15868 |<br> |
----------------------------------------------------------------- |<br> | |<br> | i.landsat.toar input_prefix="B" output_prefix="R" metfile="./L711740\ |<br> | 38_03820080324/L71174038_03820080324_MTL.txt" sensor="tm7" method="u\ |<br> | ncorrected" percent=0.01 pixel=1000 sat_zenith=8.2000 rayleigh=0.0
|<br> | |<br> +----------------------------------------------------------------------------+</div><div> +----------------------------------------------------------------------------+<br> | Layer: D.3 Date: Wed May 2 20:22:21 2012 |<br> | Mapset:
L71174038_03820080324 Login of Creator: jamie |<br> | Location: area |<br> | DataBase: /home/jamie/grassdata |<br> | Title: ( D.3
) |<br> | Timestamp: none
|<br> |----------------------------------------------------------------------------|<br> | |<br> | Type of Map: raster Number of Categories: 255 |<br> | Data Type:
DCELL |<br> | Rows: 334 |<br> | Columns:
166 |<br> | Total Cells: 55444 |<br> | Projection: UTM (zone
36) |<br> | N: 3493000 S: 3483000 Res: 29.94011976 |<br> | E: 649000 W: 644000 Res: 30.12048193 |<br> | Range of data: min = -0.463376848126162 max = 0.19725822381175
|<br> | |<br> | Data Description: |<br> | generated by
r.mapcalc |<br> | |<br> |
Comments: |<br> | R3 - (TC.4 - 0.134975) * -3.08586
|<br> | |<br> +----------------------------------------------------------------------------+<br></div><div></div></div></body></html>