Using appliercontrols for more control over output in RIOS

For more control over writing files in RIOS, you can use the controls class, documented here. The basic usage is to create a ‘controls’ class and pass this to the ‘apply’ function:

from rios import applier
infiles = applier.FilenameAssociations()
infiles.inimage = 'in_image.kea'

outfiles = applier.FilenameAssociations()
outfiles.outimage = 'out_image.kea'

controls = applier.ApplierControls()
applier.apply(userFunc, infiles, outfiles, controls=controls)

Display progress

from rios import cuiprogress
controls.progress = cuiprogress.CUIProgressBar()

Set output driver and creation options

controls.setOutputDriverName("ENVI")
controls.setCreationOptions(["INTERLEAVE=BIL"])

For more information on this, see previous post. For supported creations options for each driver see http://www.gdal.org/formats_list.html.

Re-project data on-the-fly
If the data are different projections you can reproject them to a reference image using:

controls.setReferenceImage(infiles.inimage)
controls.setResampleMethod("near")

Where any of the resampling methods supported by GDAL can be used. A list is available in the gdalwarp documentation.

Set output layer as thematic

controls.setThematic(True)

Set output later names

controls.setLayerNames(['HH','VV','HV'])

Set no data value

controls.setStatsIgnore(0)

This sets the global default value to use as the null value when calculating stats.

Other
For a full list open an interactive Python session and type:

help(rios.applier.ApplierControls)

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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