Skip to end of metadata
Go to start of metadata

Overview

This is a sample Python script that utilizes Opticks and the Python Scripting Extension for Opticks. This script loads Landsat 5/7 data, freely available from USGS Glovis. Specifically, you can load the VNIR/SWIR, TIR and PAN into their own image. After loading the data, you can convert the VNIR/SWIR data into calibrated radiance or you can convert the VNIR/SWIR data into at sensor solar corrected reflectance. This script also includes the ability to convert the TIR data into temperature in Kelvin.

What Will I Learn?

You will learn the following about the Python scripting extension for Opticks:

  • How to get the current window.
  • How to get the raster data of a given window.
  • How to execute an Opticks plug-in from Python.
  • How to copy and manipulate group control points.
  • How to use NumPy to perform conversion of Landsat data into radiance, reflectance and temperature.
  • How to report progress
  • How to deal with errors.
  • How to create menu items that the user can simply click on.
  • How to load images from the disk.
  • How to prompt the user for a filename.
  • How to create a new window for an image.
  • How to set the displayed bands for an image.

What Do I Need?

  • Opticks - you will need 4.5.0 or later. Opticks 4.5.X, 4.6.X and 4.7.X are known to work.
  • Python Scripting Extension For Opticks - recommend installation of the Python 2.6.X version of the extension.
  • You will need to have a local install of Python which includes the NumPy extension. A good distribution for Windows is the Python (x,y) distribution.
  • Landsat 5 or Landsat 7 imagery, specifically the Level 1 Product. Freely available from USGS Glovis.

The Script

You can read the Python code with the following steps:

  1. Download the AEB and rename to have an extension of .zip.
  2. Extract the contents of the .zip file.
  3. Look for the script landsat.py in content/SupportFiles/site-packages.
  4. Edit landsat.py in your text editor of choice.

This script is intended to be used by example and therefore it will not be explained in detail.

Quick Start

  1. Download and install everything listed under "What Do I Need?"
  2. Download the Landsat script bundled into an Opticks extension and install it. See How To Install an Extension for details on installing.
  3. Start up Opticks and display the "Landsat" toolbar if it isn't already visible.
  4. To Load Landsat 5/7 data, click on "Landsat" and then "Open File - Load All" which will prompt you to locate the Landsat 5/7 file you wish to load. It will then load the VNIR/SWIR data into one window and the TIR data into another window. If you selected a Landsat 7 file, it will also load the PAN data into another window. If you only wish to load one of those types of data, click on one of the other "Open File" menu items.
  5. To convert VNIR/SWIR data into At Sensor Solar Corrected Reflectance, you must have already loaded the data and that window must be the active window. At this point, click on "Landsat" and then "Convert VNIR-SWIR data into At Sensor Reflectance".
  6. To convert VNIR/SWIR data into Calibrated Radiance, you must have already loaded the data and that window must be the active window. At this point, click on "Landsat" and then "Convert VNIR-SWIR data into Radiance".
  7. To convert TIR data into Temperature, you must have already loaded the data and that window must be the active window. At this point, click on "Landsat" and then "Convert TIR data into Temperature".
  8. You can find the Python script in "OPTICKS_INSTALL\SupportFiles\site-packages\landsat.py", assuming you installed the script as detailed in step 2.
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.