MATLAB Examples

L8read documentation

The L8read function reads full-resolution Level 1 Landsat 8 images and has the ability to subset the image before loading.

Contents

Syntax

I = L8read(foldername)
I = L8read(...,lat,lon)
I = L8read(...,x,y)
I = L8read(...,buffer)
I = L8read(...,'band',band)
I = L8read(...,'stretch')
[I,x,y,info] = L8read(...)
L8read(...)

Description

I = L8read(foldername) returns a full natural color RGB image. Loading an entire Level 1 Landsat 8 image will take a few seconds. The foldername is the name of the folder containing band-level tiff images. The foldername is what Earth Explorer calls the Entity ID.

I = L8read(...,lat,lon) loads only a region large enough to encompass all geo coordinates given by lat,lon. Specifying lat,lon requires Matlab's Mapping Toolbox, but specifying x,y does not.

I = L8read(...,x,y) loads only a region large enough to encompass all projected coordinates given by x,y. Coordinates x and y are in meters and projection information can be determined by exploring the information of one individual band tiff files with imfinfo(filename).

I = L8read(...,buffer) specifies a buffer around any specified lat,lon or x,y in units of meters. To center a 20 km wide image on a single point, specify the single point as lat,lon or x,y and set the buffer value to 10e3 meters. The buffer value may be a two-element vector to specify different buffer sizes in width and height, respectively.

I = L8read(...,'band',band) specifies a Landsat 8 band to load. band can be any number 1 through 11, 'qa' for quality, or 'rgb' for a natural color RGB image. Default band is 'rgb' which concatenates bands 4, 3, and 2, respectively to create an RGB image.

I = L8read(...,'stretch') uses the Image Processing Toolbox functions imadjust and stretchlim to stretch the limits of the image, thereby maximizing contrast.

[I,x,y,info] = L8read(...) returns x and y coordinates in meters as well as meta data info.

L8read(...) without any outputs displays the image with imagesc.

Examples

From Earth Explorer I downloaded path 27, row 39 from August 31, 2013, Entity ID LC80270392013243LGN00. When you download the Level 1 data, it will be about a gigabyte of zipped data and when you unzip the folder the foldername will be the same as the Earth Explorer Entity ID. For a quick look at the entire scene, make sure your current folder contains the LC80270392013243LGN00 and try this:

L8read('LC80270392013243LGN00')

If you prefer a 20 km wide image centered on the Texas State Capitol building, specify the Capitol coordinates and a 10 km buffer around the center coordinates. I'll also use the 'stretch' option to give the image more contrast:

L8read('LC80270392013243LGN00',30.274722,-97.740556,10e3,'stretch');

If you prefer to get the image data into the Matlab workspace, simply include function outputs. Here we load band 5 which covers the near-infrared range. And instead of specifying a single centerpoint, I'll say we have 7 locations we're interested in that surround the Austin airport. We only want to load enough data to surround the airport, plus an additional 3000 meters on each side, 1500 meters on top, and 1500 meters below the seven points. The seven points surrounding the airport may be specified in geo coordinates as above, or in meters, UTM Zone 14:

Xpts = [626975;626650;626609;627910;629659;630106;629293];
Ypts = [3343378;3341833;3340043;3339068;3339108;3341467;3343378];

[I,x,y] = L8read('LC80270392013243LGN00',Xpts,Ypts,[3000 1500],'band',5);

figure
imagesc(x,y,I)
colormap(gray)
axis xy equal
hold on
plot(Xpts,Ypts,'gp')

Author Info

The L8read function and supporting documentation were written by Chad A. Greene of the University of Texas at Austin's Institute for Geophysics (UTIG), January 2016. L8read uses Aslak Grinsted's geoimread function to accomplish regional loading.