Create Colour Composites for ALOS PALSAR Tiles

A common way to visualise dual-polarisation SAR data is to display a colour composite of HH (Red), HV (Green) and HH/HV(Blue).

Python Functions

Such composites can be created in RSGISLib using the following steps:

  1. Create the ratio image using the bandMath.
    import rsgislib
    from rsgislib import imagecalc
    bandDefns = [imagecalc.BandDefn('hh', 'in_hh_file.kea', 1),
                 imagecalc.BandDefn('hv', 'in_hv_file.kea', 1)]
    imagecalc.bandMath('out_hhhv_ratio.kea', 'hh/hv', 'KEA', \
                      rsgislib.TYPE_32FLOAT, bandDefns) 
  2. Create the stack using stackImageBands
    import rsgislib
    from rsgislib import imageutils
    bands_list = ['in_hh_file.kea', 'in_hv_file.kea', 'out_hhhv_ratio.kea']
    band_names = ['HH','HV', 'HH/HV']
    gdaltype = rsgislib.TYPE_32FLOAT
    imageutils.stackImageBands(bands_list, band_names, 'out_hhhvratio_stack.kea', None, 
                                        0, 'KEA', rsgislib.TYPE_32FLOAT) 
  3. Stretch using stretchImage
    import rsgislib
    from rsgislib import imageutils
    imageutils.stretchImage('out_hhhvratio_stack.kea, 'out_hhhvratio_stack_scale.kea', \
           False, '', True, False, 'GTiff', 
           rsgislib.TYPE_8INT, imageutils.STRETCH_LINEARSTDDEV, 2)

    This will create a tiff with values between 0 – 255 (8 bit), suitable for display in GIS packages or graphics programs such as Photoshop / GIMP.

Script for ALOS PALSAR tiles

For the 1×1 degree 25 m resolution ALOS PALSAR tiles, which can be freely downloaded from for 2007 – 2010. A script ( is available from RSGIS Scripts on Bitbucket. The script will also untar files, and can be run on downloaded data using:

python —unzip downloaded_palsar_files

The script will untar each tile into a separate directory, create temp files for the ratio image and stack and save a tiff in with the original date files in the following structure:

     |-----N63W165_10_MOS.tar.gz - Original tar.gz
     |-----N63W165_10_MOS_composite.tif - Composite generated
     |-----N63W165_10_date       - Acquisition date of each pixel
     |-----N63W165_10_linci      - Local incidence angle for each pixel
     |-----N63W165_10_mask       - Data / no-data mask
     |-----N63W165_10_sl_HH      - HH data (DN)
     |-----N63W165_10_sl_HV      - HV data (DN)

The resulting tiff will be something like the example below (Alaska; 63N165W)

Data Copyright JAXA

To apply the same stretch to multiple files a text file can be used with the minimum and maximum values for each band. For example:


This stretch file is specified using:

python --unzip --stretchtxt stats.txt downloaded_palsar_files

It is also possible to create a stack using the coefficient of variance as the third band using:

# Coefficient of variance HH
python --unzip --CoVHH downloaded_palsar_files 
# Coefficient of variance HV
python --unzip --CoVHV downloaded_palsar_files

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s