---
name: i.oif
description: Calculates Optimum-Index-Factor table for spectral bands
keywords: [ imagery, multispectral, statistics ]
---

# i.oif

Calculates Optimum-Index-Factor table for spectral bands

=== "Command line"

    **i.oif**
    [**-gs**]
    **input**=*name* [,*name*,...]
    [**output**=*name*]
    [**--overwrite**]
    [**--verbose**]
    [**--quiet**]
    [**--qq**]
    [**--ui**]

    Example:

    ```sh
    i.oif input=name
    ```

=== "Python (grass.tools)"

    *grass.tools.Tools.i_oif*(**input**,
        **output**=*None*,
        **flags**=*None*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    tools = Tools()
    tools.i_oif(input="name")
    ```

    This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

=== "Python (grass.script)"

    *grass.script.run_command*("***i.oif***",
        **input**,
        **output**=*None*,
        **flags**=*None*,
        **overwrite**=*None*,
        **verbose**=*None*,
        **quiet**=*None*,
        **superquiet**=*None*)

    Example:

    ```python
    gs.run_command("i.oif", input="name")
    ```

## Parameters

=== "Command line"

    **input**=*name* [,*name*,...] **[required]**  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input raster map(s)  
    **output**=*name*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file (if omitted or "-" output to stdout)  
    **-g**  
    &nbsp;&nbsp;&nbsp;&nbsp;Print in shell script style  
    **-s**  
    &nbsp;&nbsp;&nbsp;&nbsp;Process bands serially (default: run in parallel)  
    **--overwrite**  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    **--help**  
    &nbsp;&nbsp;&nbsp;&nbsp;Print usage summary  
    **--verbose**  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    **--quiet**  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    **--qq**  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    **--ui**  
    &nbsp;&nbsp;&nbsp;&nbsp;Force launching GUI dialog

=== "Python (grass.tools)"

    **input** : str | list[str], *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input raster map(s)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, raster, *name*  
    **output** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file (if omitted or "-" output to stdout)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, file, *name*  
    **flags** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *g*, *s*  
    &nbsp;&nbsp;&nbsp;&nbsp;**g**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Print in shell script style  
    &nbsp;&nbsp;&nbsp;&nbsp;**s**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process bands serially (default: run in parallel)  
    **overwrite** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **verbose** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **quiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **superquiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  

    Returns:

    **result** : grass.tools.support.ToolResult | None  
    If the tool produces text as standard output, a *ToolResult* object will be returned. Otherwise, `None` will be returned.

    Raises:

    *grass.tools.ToolError*: When the tool ended with an error.

=== "Python (grass.script)"

    **input** : str | list[str], *required*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name of input raster map(s)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: input, raster, *name*  
    **output** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Name for output file (if omitted or "-" output to stdout)  
    &nbsp;&nbsp;&nbsp;&nbsp;Used as: output, file, *name*  
    **flags** : str, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allowed values: *g*, *s*  
    &nbsp;&nbsp;&nbsp;&nbsp;**g**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Print in shell script style  
    &nbsp;&nbsp;&nbsp;&nbsp;**s**  
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Process bands serially (default: run in parallel)  
    **overwrite** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Allow output files to overwrite existing files  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **verbose** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Verbose module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **quiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*  
    **superquiet** : bool, *optional*  
    &nbsp;&nbsp;&nbsp;&nbsp;Very quiet module output  
    &nbsp;&nbsp;&nbsp;&nbsp;Default: *None*

## DESCRIPTION

*i.oif* calculates the Optimum Index Factor for multi-spectral satellite
imagery.

The Optimum Index Factor (OIF) determines the three-band combination
that maximizes the variability (information) in a multi-spectral scene.
The index is a ratio of the total variance (standard deviation) within
and the correlation between all possible band combinations. The bands
that comprise the highest scoring combination from *i.oif* are used as
the three color channels required for *d.rgb* or *r.composite*.

The analysis is saved to a file in the current directory called
"i.oif.result".

## NOTES

Landsat 1-7 TM: Colour Composites in BGR order as important Landsat TM
band combinations (example: 234 in BGR order means: B=2, G=3, R=4):

- 123: near natural ("true") colour; however, because of correlation of
  the 3 bands in visible spectrum, this combination contains not much
  more info than is contained in single band.
- 234: sensitive to green vegetation (portrayed as red), coniferous as
  distinctly darker red than deciduous forests. Roads and water bodies
  are clear.
- 243: green vegetation is green but coniferous forests aren't as clear
  as the 234 combination.
- 247: one of the best for info pertaining to forestry. Good for
  operation scale mapping of recent harvest areas and road construction.
- 345: contains one band from each of the main reflective units (vis,
  nir, shortwave infra). Green vegetation is green and the shortwave
  band shows vegetational stress and mortality. Roads are less evident
  as band 3 is blue.
- 347: similar to 345 but depicts burned areas better.
- 354: appears more like a colour infrared photo.
- 374: similar to 354.
- 457: shows soil texture classes (clay, loam, sandy).

By default the module will calculate standard deviations for all bands
in parallel. To run serially use the **-s** flag. If the `WORKERS`
environment variable is set, the number of concurrent processes will be
limited to that number of jobs.

## EXAMPLE

North Carolina sample dataset:

```sh
g.region raster=lsat7_2002_10 -p
i.oif input=lsat7_2002_10,lsat7_2002_20,lsat7_2002_30,lsat7_2002_40,lsat7_2002_50,lsat7_2002_70
```

## REFERENCES

Jensen, 1996. Introductory digital image processing. Prentice Hall,
p.98. ISBN 0-13-205840-5

## SEE ALSO

*[d.rgb](d.rgb.md), [r.composite](r.composite.md),
[r.covar](r.covar.md), [r.univar](r.univar.md)*

## AUTHORS

Markus Neteler, ITC-Irst, Trento, Italy  
Updated to GRASS 5.7 by Michael Barton, Arizona State University

## SOURCE CODE

Available at: [i.oif source code](https://github.com/OSGeo/grass/tree/main/scripts/i.oif)
([history](https://github.com/OSGeo/grass/commits/main/scripts/i.oif))  
Latest change: Tuesday Oct 21 09:57:14 2025 in commit [fb0165c](https://github.com/OSGeo/grass/commit/fb0165c2d021b7700528aca09c224847be871729)
