Linux Landsat Tutorial, Part I

Ok, so you wanna know a little about fooling around with satellite imagery? Specifically on Linux?

Here's some ins and outs of how I do it. Keep in mind I am not a trained professional and wouldn't try this on an open road, without the prper safety equipment or without adult supervision. Your mileage may vary, keep your arms and legs in at all times, no refunds, batteries not included etc etc.

You will need a good image analysis program. You can buy some professional programs anywhere from $100 to $3500 but this is Linux, we ain't payin' for nothin'. I recommend Tnimage (a scientific image analysis program written primarily for the medical field) which works great for me. Be skeptical of other programs because as this page shows, many programs discard information that can be very important in performing mathematical operations on the image because they are only designed to display them, not do the math.

It's optional, but I also use Imview to preview the imagery for a couple of reasons. Number one is that my computer isn't that fast (1.2 GHz with 512 MB RAM), and secondly because Tnimage is a little slow in opening huge files (these images can range from 60 to over 200 MB).

It also doesn't hurt to have Imagemagick, most Linux systems should already have it. We don't need it for this, but one day it will come in very handy.

On to the fun stuff.

First thing you do is head on over to the Earth Science Data Interface (ESDI) at the Global Land Cover Facility to get your raw data.

Well, semi-raw anyway. They come as orthorectified tiff files. "Orthorectified" means north is up and that everything in the image is flat and shaped like it's supposed to be. Taking images from satellites is a complicated business and most raw images start out having geometric distortions due to the curvature or rotation of the earth, atmospheric conditions, the flight path of the satellite and a million other things. Luckily they are rectified by professional geeks and the end result is an image that is so accurate that you can use it as a map.

Anyway, you're at the ESDI. The map search is probably the best thing for a beginner. Just click on the map until you find the place you want then select the satellite you want at the left and click the "select window" thing at the top of the map. If there is imagery for that location a red patch will cover that section of the map, then you can preview and download.

I'll let you figure out the map, let's download the imagery and get started. Click here for an ftp directory. These images cover the area in red as shown below.

Image Hosted by ImageShack.us

You will find these files:


The actual image data are the "tif.gz" files. The "browse.jpg" are just a small sample of the imagery that you may find interesting. The ".met" files are metadata files that you don't need to worry about, but check them out if you're curious.

What you generally want are the following files:


which correspond to Landsat bands 1, 2, 3, 4, 5, and 7.

61 and 62 are high/low gain thermal infrared bands and 80 is a high resolution panachromatic band. All three are totally different sizes from the regular bands and neither are easy to work with so we won't worry about those.

Download the other six bands (1, 2, 3, 4, 5, and 7) into a folder somewhere and gunzip them (I usually just do "gunzip *"). Tnimage can actually gunzip them on it's own so if you want to save some disc space you don't have to decompress them, but if you want to use Imview to preview the images they need to be gunzipped.

Now we're ready to rock. Spend some time opening the files and just looking at them until you find something interesting. Then close it and open another band and find the same thing that interested you and see if it still looks interesting. I usually use bands 4, 5 and 7 for my browsing, but use what you like.

I thought this area was interesting.

Image Hosted by ImageShack.us

I will let you find the location yourself. Hint: go to the center, then down to the left.

Now is the tricky part. Technically you are ready to do some image manipulation, but if you use the entire image that you have right now you're going to end up with images that are close to 200 megabytes in size. So let's crop them to work only with the area we are interested in.

Open the first file (p035r038_7t20000912_z12_nn10.tif) in Tnimage and use the "slew" button and the arrow keys to find the location we are interested in (I wrote the author of Tnimage and he is working on a fix for scroll bars to make this easier). Draw a box around the section you want and pay attention to the relative coordinates on the left side. It helps to start and end the box on a good even number and write it down. My numbers 2612 and 5134 aren't easy even numbers, but that's because I had to move the mouse to make the snapshot.

Image Hosted by ImageShack.us

Once you have a set of numbers that correspond to the area you want to crop, close the image and open it back up again. Once it's reopened, don't move it around any. Hit CTRL+i to get to the macro function and type the following substituting your coordinates for the x's and y's:

selectregion(x1, y1, x2, y2);

So if the region you want had the following coordinates:

upper left: x=2500 y=3000
lower right: x=3200 y=3800

you would enter "selectregion(2500, 3000, 3200, 3800);". Don't forget the semi-colon.

Now, make sure to move your cursor back to the left of "selectregion..." or it won't work. Hit "execute" then hit "save" (under slew and close).

In the save dialog, make sure to choose "selected region" and "8bpp gray scale image", then give the file a name like "1.tif" and hit accept. It will warn you about losing color information, but there is no color in the to begin with so click yes. It should then confirm that the file was saved.

Now, close that image and do the same thing for the rest of the landsat bands 2, 3, 4, 5 and 7. As long as you don't close Tnimage you won't have to reenter the macro.

Once you are done with all that you will have these files which correspond to their respective Landsat bands:


Close everything in Tnimage and open all those files in order starting with 1.tif. This may sound funny but open image "7.tif" twice. You'll understand in a minute.

Under the color menu, select "composite RGB". The dialog box allows you to select the images to composite. If you opened the tiffs in order, image 1 corresponds to 1.tif, 2 is 2.tif etc.. (it goes to 8 for some reason, ignore 8 and ignore 0). Remember that there is no "6.tif" so when you opened 7.tif the first time it became image 6. But since you opened it twice, image 7 is 7.tif. See? That just makes it simpler to do combinations with band 7 without having to remember that 7=6. Right?

Now just select three images you want to composite. I have examples of all 120 possible combinations that can give you some ideas for useful and useless combinations, but it's more fun if you simply combine them yourself and see the results.

If you are reading up on band combinations on other websites, make sure you know which order they're talking about with the combinations. Technically "RGB" is backwards and many people speak in terms of "BGR". In the electromagnetic spectrum blue has the shortest wavelength followed by green then red, thus Landsat bands are blue=1, green=2 and red=3 and the infrared bands 4, 5 and 7 increase in wavelength in that order (band 6 was originally the last band but 7 was added on late in the design process). For that reason, some BGR people will say that the natural color combination is 123 (bands 1, 2 and 3 for blue, green and red), but I think in terms of RGB and I say it's 321. Whadda they know?

Those are the basics to working with the images. You now know enough to have some fun on your own. Practice students! Next post on this subject, which will come whenever I have time and feel like it, will get into interpretation and classification. The object of remote sensing is to identify everything in an image and that's what we're going to try and do. If you want to free up disc space go ahead but save those six cropped images, we'll be using them next time.

<< Home

This page is powered by Blogger. Isn't yours?