% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/rsebstack.R
\name{sebkcstack}
\alias{sebkcstack}
\alias{sebkcstack.default}
\title{Stacking, gap-filling, cloud removal of Landsat image ET Model}
\usage{
sebkcstack(
  folder,
  meta_pattern = "MTL.txt",
  remove_cloud = FALSE,
  gap_fill = FALSE,
  gap_loop = 8,
  clip = NULL
)

\method{sebkcstack}{default}(
  folder,
  meta_pattern = "MTL.txt",
  remove_cloud = FALSE,
  gap_fill = FALSE,
  gap_loop = 8,
  clip = NULL
)
}
\arguments{
\item{folder}{The folder or directory of landsat files}

\item{meta_pattern}{The regular expression pattern to identify 
metadata file. The default is "MTL.txt". The function works 
on the new landsat metadata only.}

\item{remove_cloud}{TRUE FALSE, 1, or 2. To indicate the cloud cover removal
from the image. Default is FALSE. If it is set to 1, 
the overlapping areas of  band 1 DN values between 120 and 255 and band 6
DN values of 102 to 128 are used. If it is set to 2 the union of the DN
ranges are used; and clouds as well as urban, barren, quarries, rocks, 
and sand are removed; otherwise only clouds are removed. 
See Martinuzzi et al(2009) for more details. 
At the moment only landsat 5 and 7 clouds are removed.}

\item{gap_fill}{Logical (TRUE or FALSE).It replaces strips in 
landsat 7 or NAs in other data set. It uses  \code{\link[raster]{focal}} 
neighbourhood approach. It is an automated Version of USGS "Gap-Filling Landsat
 7 SLC-off Single Scenes Using Erdas Imagine TM". Like USGS, it also takes 
 approximately one hour to complete.
 see details at http://landsat.usgs.gov/ERDAS_Approach.php}

\item{gap_loop}{numeric. The number of loops or repetitions that gap-fill 
should be run. The default is 8 for one landsat scene. If the landsat image
is smaller, it can be reduced.}

\item{clip}{extent object or raster object or polygon from which an Extent 
object can be extracted. A polygon or raster will be reprojected to 
conform the data to be cropped. for example clip can take the form of c(xmin, xmax, ymin, ymax)}
}
\value{
\describe{
\item{data:}{ raster stacked data. If crop is not NULL then  crop Extent object is returned}
\item{brescale:}{ brescale of the stacked data}
\item{grescale:}{ grescale of the stacked data}
\item{sunelev:}{ sun elevation for stacked data}
\item{date:}{ Acquired date of the raster stacked data}
\item{viewangle:}{ view angle of landsat 8}
\item{azimuth:}{ azimuth angle of the image}
\item{sensor:}{ Type of satellite}
\item{K1:}{ K1 of landsat 8 thermal band 10}
\item{K2:}{ K2 of landsat 8 thermal band 10}
\item{cc:}{ cloud cover percentage}
\item{quality:}{ Image quality}
\item{row:}{ WRS_ROW of the image }
\item{path:}{ WRS_PATH of the image}
}
}
\description{
This function prepares landsat 5, 7, and 8 data for  
\code{\link{landsat578}}. First, it reads meta data and returns many 
input parameters for \code{\link{landsat578}} and \code{\link{sebal}}.
 Second, it stacks 7 landsat layers: it stacks bands 1-7 for landsat 5 and 7; 
and bands 2-7,10 for landsat 8.. Third, it removes landsat clouds based 
 on Martinuzzi et al(2009) method. Fourth, it gap-fills landsat 7 strips 
 due to SLC-off as well as gap-filling NAs in other landsat sensors. 
 It can also process any selected bands.
}
\details{
The function can simulate any of the activities described in the 
description section. It takes several minutes to replace strips (1 hour) 
and remove clouds (30 minutes) on one landsat scene. But stacking of bands 
and reading of metadata take few seconds. One can save the stacked and 
processed data in the same "folder" with \code{\link{writesebkc}}. 
The output file name is "sebkcstack.tif".
}
\examples{
\dontrun{
folder=system.file("extdata","stack",package="sebkc")
stack=sebkcstack(folder=folder)
#returns data and grescale
stack$data
stack$grescale
}
}
\references{
Martinuzzi, S., Gould, W.A., Ramos Gonzales, O.M. 2007.
Creating Cloud-Free Landsat ETM+ Data Sets in Tropical Landscapes: 
Cloud and Cloud-Shadow Removal. USDA Forest Service General Technical 
Report IITF-GTR-32.

USGS Using Landsat 7 Data http://landsat.usgs.gov/ERDAS_Approach.php
}
\author{
George Owusu
}
