Overview
This post outlines how to use the teamlucc
package to preprocess imagery from
the Landsat Surface Reflectance Climate Data Record
(CDR) archive. The teamlucc
package
supports a number of common preprocessing steps, including:
- Conversion of CDR files to any GDAL supported file format
- Cropping Landsat tiles to a given area of interest (AOI)
- Mosaicking and cropping of DEM tiles (such as ASTER or SRTM) to a given AOI or Landsat path/row
- Topographic correction of CDR scenes
Getting started
First load the teamlucc
package, and the rgdal
package:
DEM setup
Before CDR surface reflectance images can be topographically corrected with
teamlucc
, a digital elevation model (DEM) needs to be obtained that is in the
same resolution and coordinate system as the CDR imagery, and slope and aspect
need to be calculated. The auto_setup_dem
function in the teamlucc
package
facilitates this task. There are many options you can supply to
auto_setup_dem
- see ?auto_setup_dem
for more information on these options.
If you do not want to topographically correct your imagery, you can skip this
step and move ahead to the next section.
auto_setup_dem
assembles a DEM to cover a given area of interest (AOI), and
can mosaic multiple DEM files if needed to cover an AOI. To use
auto_setup_dem
, the user must first define the area of interest with an AOI
polygon. If you have a shapefile of an area of interest, load it into R using
the readOGR
command. The readOGR
command needs the folder the shapefile is
in (in this example the current working directory, specified by .
) as the
first parameter, and the filename of the shapefile (without the “.shp”
extension) as the second parameter (PA_VB
) in this example). This example
uses a shapefile of the boundary of the Braulio Carrillo National Park, in
which the Volcán Barva TEAM
site is located:
As seen in the above plot, there are a number of adjoining polygons in this
shapefile. The functions in teamlucc
expect the AOI to be of length one. So
calculate the convex hull of the AOI using the functions in the rgeos
package:
The AOI is now a single polygon:
If you do not have an AOI, but know the Landsat path and row you want to work
with, an alternative is to define the AOI based on the path and row, using the
wrspathrow
R package, and supplying the desired path and row numbers. Here
127
is the WRS-2 path number, and 47
is the WRS-2 row number for the
path/row at the center of the above AOI:
In addition to the AOI, auto_setup_dem
needs to know the location and spatial
extents of the DEM files you have available on your machine. This list can be
assembled automatically using the get_extent_polys
function in teamlucc
.
See ?get_extent_polys
for more information. The below code will fail on your
machine because you will not have the proper DEMs for this example. Download
the proper DEMs for the area in which you are working and place them in a
folder on your machine if you want to test this function.
For flexibility, auto_setup_dem
can optionally crop each output DEM to the
spatial extent of the supplied AOI. If crop_to_aoi=TRUE
, then
auto_setup_dem
will crop the DEMs to the spatial extent of the supplied AOI.
If crop_to_aoi=FALSE
, then auto_setup_dem
will crop the DEMs to the extent
of the Landsat path/rows needed to cover the AOI.
Lastly, auto_setup_dem
needs to know where to save its output. For this
example, save the output to the current working directory .
. Now that all of
the essential inputs are defined, auto_setup_dem
can be called:
The result will be a mosaicked DEM, in the current working directory, that can
be used for topographically correcting imagery with the
auto_preprocess_landsat
function.
Preprocessing
Images are delivered from the CDR archive in either ENVI format, GeoTIFF
format, or Hierarchical Data Format (HDF). The teamlucc
package will, by
default, convert HDF or ENVI format images to a GeoTIFF format, as these image
files can be easily read in R and in most commonly used remote sensing and GIS
software packages. This example assumes you want GeoTIFF output - see the help
files for teamlucc
for other output options.
First you will need to acquire a time series of CDR imagery for your site. The
espa_download
function can facilitate downloading files from an ESPA order.
Also see the post on Filtering and downloading Landsat
scenes for more details on how
teamlucc
can help with image acquisition.
Once you have downloaded your imagery from ESPA, I recommend you put all of the
zip files from your download in a single folder. You can then use the
teamlucc
espa_extract
function to automate extracting your CDR image files,
including placing the extracted files in consistently named output folders.
If, for example, your files are located in espa_downloads
and you want to
extract them to espa_extracts
, run the following (this block, and the next
block of code, will both fail on your computer since you do not have the
required imagery - this is only an example, download your own imagery to follow
along):
Now that the CDR format image files are extracted, you are ready to run
auto_preprocess_landsat
. As with auto_setup_dem
, there are many options you
can supply to auto_preprocess_landsat
- see ?auto_preprocess_landsat
. The
below is a simple example of how to call auto_preprocess_landsat
.
The image_dirs
line below is just a fancy way of finding all the folders
located in extract_folder
that contain CDR imagery. You could just as easily
specify these folders individually as as a list of strings, like: image_dirs
<- c('C:/folder1', 'C:/folder2')
if you had two CDR Landsat scenes located in
C:/folder1
and C:/folder2
, respectively.
The prefix
parameter specifies a string that will be used in naming files
output by auto_preprocess_landsat
. For prefix
I suggest you use a short (2
or 3 character) site name or site code that is meaningful to you.
There are two other options we provide below to auto_preprocess_landsat
.
tc=TRUE
tells auto_preprocess_landsat
to perform topographic correction.
Because of this, we also need to specify dem_path
(where the DEM files
preprocessed by auto_setup_dem
are located), so that the DEM files for this
scene can be found. Here we set dem_path='.'
as the DEM is in our current
working directory. We supply an AOI (same AOI as above) to crop the output
images. verbose=TRUE
indicates that we want detailed progress messages to
print while the script is running. The output of auto_preprocess_landsat
is a
data.frame
with a list of the preprocessed files and their file formats.
The result is two cropped, reprojected, and topographically corrected Landsat images covering the specified AOI. One image from 2000:
And one image from 2001:
There is a fair amount of cloud cover in the 2000 image. See the post on cloud removal for one means of addressing this issue.