lookuplinear

lookuplinear

Assigns table key values with possible interpolation between key values.

Result = lookuplinear(table,expression)
table
ascii text table
expression
scalar, spatial, non-spatial
Result
scalar, spatial

Operation

The value of expression is compared to the values of the search key (first column) of the table and is assigned the value of the corresponding record (second column) on the same row if the expression matches the value of the search key. If the value of expression lies between two values of the search key of the table a linear interpolation is executed between the two corresponding records. The interpolation is executed according to the formula:

Result = ((expression – lowerKey) / (upperKey – lowerKey)) * (lowerRecord – upperRecord) + lowerRecord

Notes

If the cell value of the expression lies outside the range of the search key a missing value is assigned. If a cell of the expression has a missing value a missing value is assigned to the result. The search key values of the table should be in ascending order or missing values are assigned to all cells of Result.

Examples

  1. • pcrcalc
    binding
    Result1 = Result1.map;
    Table = Table.txt;
    Expr = Expr.map;
    initial
    report Result1 = lookuplinear(Table,Expr);

    • python
    Table = “Table.txt”
    Expr = readmap(“Expr.map”)
    Result1 = lookuplinear(Table,Expr)
    Result1.map Table.txt Expr.map
    _images/lookuplinear_Result1.png
    0  0
    2  1
    5  1
    7  0
    
    _images/lookuplinear_Expr.png

  2. • pcrcalc
    binding
    Result2 = Result2.map;
    Table2 = Table2.txt;
    Expr2 = Expr2.map;
    initial
    report Result2 = lookuplinear(Table2,Expr2);

    • python
    Table2 = “Table2.txt”
    Expr2 = readmap(“Expr2.map”)
    Result2 = lookuplinear(Table2,Expr2)
    Result2.map Table2.txt Expr2.map
    _images/lookuplinear_Result2.png
    0    0
    2    1
    500  1
    
    _images/lookuplinear_Expr2.png

Table Of Contents

Previous topic

lookup

Next topic

lookupmapstack