| Environments | PYTHON :: EASI :: MODELER |
| Quick links | Description :: Parameters :: Parameter descriptions :: Details :: Examples :: Related |
| Back to top |
| Back to top |
rtr(file, cnum, wnum, ncon, cden, wden, dcon, filo, dboc, datatype, smod, mask, zerodiv, ftype, foptions)
| Name | Type | Caption | Length | Value range |
|---|---|---|---|---|
| FILE * | str | Input file name | 1 - | |
| CNUM * | List[int] | Input channels for ratio numerator | 1 - 16 | -1024 - |
| WNUM | List[float] | Weights for ratio numerator | 0 - 16 | Default: 1.0 |
| NCON | List[float] | Constant for ratio numerator | 0 - 1 | Default: 0.0 |
| CDEN | List[int] | Input channels for ratio denominator | 0 - 16 | -1024 - |
| WDEN | List[float] | Weights for ratio denominator | 0 - 16 | Default: 1.0 |
| DCON | List[float] | Constant for ratio denominator | 0 - 1 | Default: 0.0 |
| FILO | str | Name of the output file | 0 - | |
| DBOC | List[int] | Output raster channel | 0 - 1 | |
| DATATYPE | str | Output raster type | 0 - 3 | 8U | 16S | 16U | 32R Default: 32R |
| SMOD * | str | Scaling Mode | 4 - 4 | NONE | AUTO | LOGS Default: NONE |
| MASK | List[int] | Area mask | 0 - 4 | |
| ZERODIV | List[float] | Value for division by zero | 0 - 1 | |
| FTYPE | str | Output file type | 0 - 4 | Default: PIX |
| FOPTIONS | str | Output file options | 0 - |
| Back to top |
FILE
Specifies the name of the PCIDSK file that contains the channels to ratio.
CNUM
Specifies the input image channels that will be added together to form the ratio numerator.
Up to 16 channels can be specified; at least one must be specified. Duplicate channels are NOT allowed.
WNUM
Optionally specifies the weights to be assigned to channels listed in the numerator.
The weights correspond to the input channels listed in CNUM (InputNumer) by their position in the list.
NCON
Optionally specifies a REAL constant to be added to the numerator.
CDEN
Optionally specifies the image channels (up to 16) to be added together to form the ratio denominator.
Up to 16 channels can be specified. Duplicate channels are NOT allowed.
WDEN
Optionally specifies weights to be assigned to channels listed in the denominator.
The weights correspond to the input channels listed in CDEN (InputDenom) by their position in the list.
DCON
Optionally specifies a REAL constant to be added to the denominator.
FILO
The name of the output file to which to write the processed data.
If the output file does not exist, one is created based on the type specified for the FTYPE parameter and the options specified for the FOPTIONS parameter. The file will have the number of channels required and have the same geocoding information and metadata as the input file.
If the output file is an existing file, it must be in a format that can be updated. The file must also contain channels suitable for writing the results, as specified by the value of the DBOC parameter.
When you specify an existing file, you need not specify a value for the FTYPE and FOPTIONS parameters unless the values of these parameters correspond to the type and options of the file; otherwise, an error may occur.
This parameter is mandatory.
DBOC
Specifies the output channel to receive the ratioed image.
if output to the new file , this parameter is ignored.
When your output file is a new file; that is, it does not exist already, you need not specify a value for this parameter; channel in the new file will be of the bit depth specified by the value of the DATATYPE parameter.
This parameter is optional.
DATATYPE
The data type of the output channel to create. When the output is written to existing channels, this parameter is ignored.
When the number of output channels is greater than one, the specified data type is used for each output channel.
This parameter is optional.
SMOD
Specifies the scaling mode.
If the specified output channel (DBOC) is 32-bit real, this parameter is ignored. See Scaling in the Details section for more information.
MASK
Specifies the window or bitmap that defines the area to be processed within the input raster.
If a single value is specified, that value represents the channel number of the bitmap segment in the input file. Only the pixels under the bitmap are processed; the rest of the image remains unchanged.
If four values are specified, they define the x,y offsets and x,y dimensions of a rectangular window identifying the area to process. Xoffset, Yoffset define the upper-left starting pixel coordinates of the window. Xsize is the number of pixels that define the window width. Ysize is the number of lines that define the window height.
If no value is specified, the entire channel is processed.
ZERODIV
Specifies the value to use for the result of a denominator equal to zero.
If this parameter is not specified, this value defaults to the maximum possible value for the specified output channel.
FTYPE
The format of the output file. The format must be a GDB-recognized type.
The default value is PIX.
For a complete list of GDB-recognized file types, see GDB-supported file formats.
FOPTIONS
The file-creation options to apply on creating the output file. These are specific to the format of the file; in each case, the default of no options is allowed. You can specify the compression schemes, file-format subtypes, and other information.
Different options are available for each type, as described for the FTYPE parameter.
For a complete list of GDB-recognized file types, including the available options for each, see GDB-supported file formats.
| Back to top |
RTR calculates any pixel by pixel ratioing transformation of the following form:
WNUM(1)*CNUM(1) + WNUM(2)*CNUM(2) + ... + WNUM(i)*CNUM(i) + NCON ---------------------------------------------------------------- WDEN(1)*CDEN(1) + WDEN(2)*CDEN(2) + ... + WDEN(i)*CDEN(i) + DCON
If weights (WNUM, WDEN) are not specified, they default to 1.0. If constants (NCON,DCON) are not specified, they default to 0. If denominator channels (CDEN) are not specified, the constant for ratio denominator defaults to 1.0.
Results of this function are saved to the specified output channel (DBOC).
The MASK parameter specifies the area within the input channel to be processed. Only the area specified under the mask is processed; the rest of the image is unchanged.
If a single value is specified, this value points to a bitmap segment that defines the area to be processed. (This is useful, for instance, for enhancing water data while leaving land data unchanged, by using a bitmap to mask all areas of water). When four values are specified, these values define the X and Y offsets and the X and Y dimensions of a rectangular window within the image to be processed.
Calculations are performed using real arithmetic. If the specified output channel is 8- or 16-bit, some loss of accuracy will occur. To help mitigate this, you can specify scaling options (SMOD).
Scaling
RTR performs ratioing transformation on 8-bit unsigned integer, 16-bit signed integer, 16-bit unsigned integer, and 32-bit real channels. These channels have the following ranges for data:
Type Min Max 8-bit unsigned integer 0 255 16-bit signed integer -32768 32767 16-bit unsigned integer 0 65535 32-bit real 1.0E38 +1.0E38
NONE: no scaling is performed. If the resulting value is less or more than the output channel can hold, it will be set to the minimum or maximum, respectively, that the channel type can hold. This option is most commonly used if the output channel is 32-bit real.
AUTO: linear scaling is performed. This is accomplished by performing two passes on the data. The first pass is used to determine the minimum and maximum values resulting from the ratioing transformation. In the second pass, these values are used to linearly scale the results to the full range of the output channel.
LOGS: logarithmic scaling is performed. This is accomplished by performing two passes on the data. The first pass is used to determine the minimum and maximum values resulting from the ratioing transformation. In the second pass, these values are used to logarithmically scale the results to the full range of the output channel.
| Back to top |
Ratio channels one and two, and overwrite channel three with the result.
from pci.rtr import rtr file = "filename" cnum = [1] # set up numerator wnum = [1] ncon = [0] cden = [2] # set up denominator wden = [1] dcon = [0] filo = "" dboc = [3] # output channel datatype = "" smod = "NONE" # do not scale output mask = [] # process entire image zerodiv = [] ftype = "" foptions = "" rtr(file, cnum, wnum, ncon, cden, wden, dcon, filo, dboc, datatype, smod, mask, zerodiv, ftype, foptions)
Average the first four channels, and save results to channel 5.
from pci.rtr import rtr file = "filename" cnum = [1,2,3,4] # set up numerator wnum = [] ncon = [] cden = [] # set up denominator wden = [] dcon = [4] filo = "" dboc = [5] # output channel datatype = "" smod = "NONE" # do not scale output mask = [] # process entire image zerodiv = [] ftype = "" foptions = "" rtr(file, cnum, wnum, ncon, cden, wden, dcon, filo, dboc, datatype, smod, mask, zerodiv, ftype, foptions)
Calculate the transformed vegetative index:
TM4 - TM3
Square root of ---------
TM4 + TM3
where TM3 and TM4 are Thematic Mapper bands 3 and 4 respectively. Assume TM3 and TM4 are on channels 3 and 4, that the output channel is 8, and unmentioned parameters are defaulted.
from pci.rtr import rtr file = "filename" cnum = [3,4] # set up numerator wnum = [-1,1] ncon = [] cden = [3,4] # set up denominator wden = [] dcon = [] filo = "" dboc = [8] # output channel datatype = "" smod = "NONE" # do not scale output mask = [] # process entire image zerodiv = [] ftype = "" foptions = "" rtr(file, cnum, wnum, ncon, cden, wden, dcon, filo, dboc, datatype, smod, mask, zerodiv, ftype, foptions)
Use STR to calculate the square root of the output channel:
from pci.str import str from pci.lut import lut file = "filename" dbic = [8] dboc = [8] expo = [0.5] # (default enhancement) dblut = [] dbsd = "" dbsn = "" istr = [] ostr = [] lctr = "" hctr = "" trim = [] mask = [] lasc = [] str( file, dbic, dblut, dbsn, dbsd, expo, istr, ostr, lctr, hctr, trim, mask,lasc ) lut( file, dbic, dblut, dboc, mask )
© PCI Geomatics Enterprises, Inc.®, 2026. All rights reserved.