Regional Trend Removal

Use the Regional Trend Removal dialog to configure how regional trends are calculated and removed during grid stitching.

Regional Trend Removal dialog options

Regional grid

Specify the reference (regional) grid used for detrending.

The regional grid must completely cover the spatial extent of all input grids involved in the stitching process.

Script Parameter: GRIDSTCH.REGIONAL

Points to use

Specify which points are used to calculate the trend:

  • All Points – Uses all data points in the grid

  • Edge Points – Uses only points along the grid edges

  • Overlap Points (default) – Uses only points within overlapping regions

  • Overlapping Edge Points – Uses only edge points within overlapping regions

Script Parameter: GRIDSTCH.REGTRCALC [0: All Points; 1: Edge Points; 2: Overlap Points; 3: Overlapping Edge Points]

(Maximum) Trend

Specify the highest order of trend that can be removed.

  • Static (zero order) – Removes a constant offset (mean value).

  • Slope (first order) – Removes a best-fit plane or linear slope.

  • 2nd order trend – Removes curved surfaces using second-order polynomial fits in X and Y.

  • 3rd order trend (default) – Removes curved surfaces using third-order polynomial fits in X and Y.

See the Application Notes below for details on how trend order interacts with RMS error tolerance.

Script Parameter: GRIDSTCH.REGTREND [1: Static, 2: Slope, 3: 2nd order trend, 4: 3rd order trend]

RMS error tolerance

Specify the RMS error threshold used to determine the appropriate trend order.

  • If provided, the system selects the lowest-order trend that satisfies the tolerance.

  • If left blank, the selected maximum trend is applied without evaluation.

Script Parameter: GRIDSTCH.REGERROR (default: left blank)

Subtract regional when done?

Choose whether the regional component is removed after stitching:

  • Yes (default) – The regional trend is subtracted from the final stitched grid

  • No – The regional trend is retained in the final grid

When grids are warped to the regional grid, the regional component is normally preserved. Enabling this option removes that component after stitching.

Script Parameter: GRIDSTCH.REGREMOVE [0: No, 1: Yes]

Application Notes

Trend removal is used to reduce differences between grids prior to stitching. The regional detrending behaviour is the same for both Knit Two Grids (GRIDSTCH GX) and Knit Multiple Grids (GRIDSTCH2 GX).

Trend Order and RMS Error Threshold

If an RMS error tolerance is specified, trend orders are evaluated incrementally from lowest to highest, up to the selected maximum. The lowest-order trend that reduces the RMS difference between the regional grid and the detrended grid below the specified tolerance is applied.

For example, let:

  • G1 = input grid

  • GR = regional grid

  • T1 = trend calculated for G1

  • TR = trend calculated for GR

The following condition is evaluated:

In practical terms:

  • The input grid (G1) is detrended using T1

  • The regional trend (TR) is then applied

  • The resulting grid is compared to the regional grid (GR)

  • The RMS difference determines whether the trend order is sufficient

If no RMS error tolerance is specified, the selected maximum trend is applied directly.

Automatic Fallback for Non-Overlapping Grids

The Points to use setting determines which points are used to calculate and remove the regional trend for each grid.

If Overlap Points or Overlapping Edge Points is selected and no overlap exists, the method automatically falls back as follows:

  • Overlap PointsAll Points

  • Overlapping Edge PointsEdge Points

This automatic fallback ensures that a trend can still be calculated even when no overlap is present.

If Edge Points is selected and the grid contains multiple disjoint regions, only the first region encountered by the algorithm is used.

Log File

The gridknit.log file is recreated each time grid stitching runs.

It records details of regional trend removal for each grid, including fallback behaviour when no overlap is detected.

Example:

...
Removing regional trend for: .\grid_name.grd(GRD)
No overlap points found for this grid.
Using all points for trend calculation.
Grid Trend - All Points
...
Interpolation

Trend calculation and removal are performed subsequent to any interpolation. (Interpolation is optional.)