[GRASS-dev] [GRASS GIS] #2089: i.landsat.toar doesn't take into account the resolution difference between panchromatic and the other bands.

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
-------------------------+--------------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
i.landsat.toar transforms the sensors DN to top of the atmosphere
radiance/reflectance.

All bands except band 8 (panchromatic) have a pixel size of 30m. Band 8
has pixel size of 15.

When i.landsat.toar runs, it makes all the calculations with g.region
res=30, which is obviously wrong for band 8.

I classify it as a a major problem , because band 8 carries double data
and its being used in pansharpening techniques .

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2089&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
-------------------------+--------------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: | Platform: All
      Cpu: Unspecified |
-------------------------+--------------------------------------------------
Changes (by vesnikos):

* cc: vesnikos (added)

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2089#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
----------------------------+-----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: i.landsat.toar | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------
Changes (by neteler):

  * keywords: => i.landsat.toar

Comment:

Did you check with the current version in GRASS 6 (the original author
confirmed the other day to me that it should behave as expected)?

Interestingly, both use the same mechanism to maintain the resolution:

{{{
[neteler@oboe ~]$ grep _get_cellhd grass64/imagery/i.landsat.toar/main.c
             if (G_get_cellhd(band_in, mapset, &cellhd) < 0)
         if (G_get_cellhd(band_in, mapset, &cellhd) < 0)

[neteler@oboe ~]$ grep _get_cellhd grass70/imagery/i.landsat.toar/main.c
             Rast_get_cellhd(band_in, "", &cellhd);
         Rast_get_cellhd(band_in, "", &cellhd);
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2089#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
----------------------------+-----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: i.landsat.toar | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by neteler):

Replying to [ticket:2089 vesnikos]:
> i.landsat.toar transforms the sensors DN to top of the atmosphere
radiance/reflectance.
>
> All bands except band 8 (panchromatic) have a pixel size of 30m. Band 8
has pixel size of 15.

Did you check the input resolution? I tested it with the Raleigh scene
LC80160352013134LGN03.tar.gz:

{{{
for i in `ls LC*.TIF` ; do echo -n "$i: " ; gdalinfo $i | grep Pixel ;
done
LC80160352013134LGN03_B10.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B11.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B1.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B2.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B3.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B4.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B5.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B6.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B7.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_B8.TIF: Pixel Size =
(15.000000000000000,-15.000000000000000)
LC80160352013134LGN03_B9.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
LC80160352013134LGN03_BQA.TIF: Pixel Size =
(30.000000000000000,-30.000000000000000)
}}}

The TIFF files are delivered as such (only B8 is 15m).

I also see that even the PAN B8 band is set to 30m in GRASS 7:
{{{
i.landsat.toar input_prefix=LC80160352013134LGN03_B output_prefix=toar \
   metfile=LC80160352013134LGN03_MTL.txt sensor=oli8 date=2013-05-14 -r
...

for i in `g.mlist rast pattern="toar*"` ; do echo "$i: " ; r.info -g $i |
grep -i res ; done
toar1:
nsres=30
ewres=30
toar10:
nsres=30
ewres=30
toar11:
nsres=30
ewres=30
toar2:
nsres=30
ewres=30
toar3:
nsres=30
ewres=30
toar4:
nsres=30
ewres=30
toar5:
nsres=30
ewres=30
toar6:
nsres=30
ewres=30
toar7:
nsres=30
ewres=30
toar8:
nsres=30 <<-- should be 15
ewres=30 <<-- should be 15
toar9:
nsres=30
ewres=30
}}}

Using

{{{
g.version -g
version=7.0.svn
date=2013
revision=57610
build_date=2013-09-08
}}}

NOTE: In GRASS 6 i.landsat.toar preserves the resolution. Must be a bug in
the
usage of Rast_get_cellhd() in the G7 version?

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2089#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
----------------------------+-----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: i.landsat.toar | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by neteler):

Perhaps this email contains relevant info:

http://lists.osgeo.org/pipermail/grass-dev/2010-July/051318.html
[GRASS-dev] Rast_set_window() changes in 7.0 - Thu Jul 22 02:57:55 EDT
2010

The problem will be in this part of G7's i.landsat.toar/main.c:
{{{
             sprintf(band_in, "%s%d", inputname, lsat.band[i].code);
             if ((infd = Rast_open_old(band_in, "")) < 0)
                 G_fatal_error(_("Unable to open raster map <%s>"),
band_in);
             Rast_get_cellhd(band_in, "", &cellhd);
             G_set_window(&cellhd);
}}}

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2089#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
----------------------------+-----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: i.landsat.toar | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by mmetz):

Replying to [comment:4 neteler]:
> Perhaps this email contains relevant info:
>
> http://lists.osgeo.org/pipermail/grass-dev/2010-July/051318.html
> [GRASS-dev] Rast_set_window() changes in 7.0 - Thu Jul 22 02:57:55 EDT
2010
>
> The problem will be in this part of G7's i.landsat.toar/main.c:
{{{
             sprintf(band_in, "%s%d", inputname, lsat.band[i].code);
             if ((infd = Rast_open_old(band_in, "")) < 0)
                 G_fatal_error(_("Unable to open raster map <%s>"),
band_in);
             Rast_get_cellhd(band_in, "", &cellhd);
             G_set_window(&cellhd);
}}}
>

Most likely. The window needs to be set 1) with Rast_set_window(), 2)
before a raster is opened. Please try r57957.

--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2089#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
----------------------------+-----------------------------------------------
Reporter: vesnikos | Owner: grass-dev@…
     Type: defect | Status: new
Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Keywords: i.landsat.toar | Platform: All
      Cpu: Unspecified |
----------------------------+-----------------------------------------------

Comment(by nikosa):

Replying to [comment:5 mmetz]:
> Replying to [comment:4 neteler]:
> > Perhaps this email contains relevant info:
> >
> > http://lists.osgeo.org/pipermail/grass-dev/2010-July/051318.html
> > [GRASS-dev] Rast_set_window() changes in 7.0 - Thu Jul 22 02:57:55 EDT
2010
> >
> > The problem will be in this part of G7's i.landsat.toar/main.c:
> {{{
> sprintf(band_in, "%s%d", inputname, lsat.band[i].code);
> if ((infd = Rast_open_old(band_in, "")) < 0)
> G_fatal_error(_("Unable to open raster map <%s>"),
band_in);
> Rast_get_cellhd(band_in, "", &cellhd);
> G_set_window(&cellhd);
> }}}
> >
>
> Most likely. The window needs to be set 1) with Rast_set_window(), 2)
before a raster is opened. Please try r57957.

It works here (revision=57968M)! Thank you.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2089#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2089: i.landsat.toar doesn't take into account the resolution difference between
panchromatic and the other bands.
-----------------------+----------------------------------------------------
  Reporter: vesnikos | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: major | Milestone: 7.0.0
Component: Imagery | Version: svn-trunk
Resolution: fixed | Keywords: i.landsat.toar
  Platform: All | Cpu: Unspecified
-----------------------+----------------------------------------------------
Changes (by neteler):

  * status: new => closed
  * resolution: => fixed

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2089#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>