Processing RADARSAT-2 imagery: reading raw data and saving RGB composites
Posted: November 12th, 2009 | Author: Benjamin | Filed under: Programming | No Comments »RADARSAT-2 imagery is delivered in GeoTiff files with an additional product.xml file which contains orbit data and ground control points. There are a few Open Source software that you could use to process this data, including RAT Radar Tools, PolSARpro, NEST, Map Ready, etc., and many proprietary software such as Geomatica, ENVI, etc. But, if all you want to do is view a calibrated image and georeference it, there is a much easier and faster way: doing it yourself in Python.
You will need to install Python (I am currently using Python 2.6 with IDLE on Mac OS 10.6), OSGEO’s GDAL, and Numpy. The first step is to import the modules:
import math
from osgeo import gdal, GDT_Float32
Next we need to use GDAL to read the product.xml file with a sigma nought calibration (this will use the sigma lookup table) and set a few variables for later.
geotransform = dataset.GetGeoTransform()
gcps = dataset.GetGCPs()
gcpproj = dataset.GetGCPProjection()
The “path” variable is set by the user at the beginning of the script. Next, we need to read those GDAL objects into Numpy arrays in scattering (Sinclair) matrix format. Less memory is required for more complex processing tasks if we keep the matrix elements in separate matrices:
S_HV = dataset.GetRasterBand(3).ReadAsArray(xoff, yoff, xdim, ydim)
S_VH = dataset.GetRasterBand(4).ReadAsArray(xoff, yoff, xdim, ydim)
S_VV = dataset.GetRasterBand(2).ReadAsArray(xoff, yoff, xdim, ydim)
The xoff, yoff, xdim and ydim variables refer to the offsets and dimensions. For example, you could analyze only a subset of the image. Now that we have the information in memory, we can generate an RBG using |HH|, |HV| and |VV| with GDAL:
g = 2 * numpy.absolute((S_HV + S_VH)/2)
b = numpy.absolute(S_VV)
driver = gdal.GetDriverByName('GTiff')
output_dataset = driver.Create(path + filename, xdim, ydim, 3, GDT_Float32, ['PHOTOMETRIC=RGB'])
output_dataset.SetGeoTransform(geotransform)
output_dataset.SetGCPs(gcps, gcpproj)
output_dataset.GetRasterBand(1).WriteArray(r, 0, 0)
output_dataset.GetRasterBand(2).WriteArray(g, 0, 0)
output_dataset.GetRasterBand(3).WriteArray(b, 0, 0)
output_dataset = None
This creates a 3-band 32-bit float RGB GeoTiff.
If you need some sample imagery to play around with, try the RADARSAT-2 demo dataset.

Leave a Reply