Grid Maths
Note
Coming in Spatial Integration version 3.
Requires the Professional edition. In the Community edition, grid files written with the Professional edition can still be loaded and viewed as surfaces.
Grid Maths combines grids cell by cell into a new grid: add two grids, subtract one survey from another, take a ratio, scale a grid to new units, or blank one grid wherever another has no data. You choose the grids, pick or write the formula, and write the result as a grid file, optionally loading it straight into the project as a surface.
The calculation is a small algorithm: a diagram of grid inputs feeding an Equation that feeds a Grid output. It is the same kind of algorithm the Imager uses, without the colours - Grid Maths keeps the numbers.
Opening the Dialog
Hover over the Data Processing icon in the right tool panel, then Interpolation, and click Grid Maths..., or drop a grid file onto that button to open it in the first grid input. Each click opens another Grid Maths window, so several calculations can be set up side by side.
The window has a toolbar across the top and shows the algorithm's diagram below it. It starts with the Add grids preset: two Grid inputs added together into a Grid output.
The Toolbar
| Button | What it does |
|---|---|
| Open | Choose a grid file for the first Grid input that has none yet |
| Preset | Start again from one of the preset calculations |
| Load | Load a saved algorithm (.sialg) |
| Save, Save as | Save the algorithm to use again |
| Export | Write the result grid to its file |
Setting Up a Calculation
- Choose a preset, or keep Add grids.
- Click each Grid input and choose its file with the browse button, or drop a grid file onto the node. Open fills the first empty Grid input.
- Click the Equation node to see or change its formula. Inputs are named i0, i1 and so on, in the order of the node's pins.
- Click Export. If the Grid output has no file yet you are asked for one first; then the output is listed with its band count and size. Click OK to write it.
Problems are shown as badges on the nodes and on the line at the bottom of the window, which otherwise shows the size of the grid that will be written.
Presets
| Preset | Formula |
|---|---|
| Add grids | i0 + i1 |
| Subtract grids | i0 - i1 |
| Multiply grids | i0 * i1 |
| Divide grids | i0 / i1 |
| Average grids | (i0 + i1) / 2 |
| Minimum of grids | min(i0, i1) |
| Maximum of grids | max(i0, i1) |
| Absolute difference | abs(i0 - i1) |
| Normalised difference | (i0 - i1) / (i0 + i1) |
| Mask by grid | i0 + 0 * i1, the first grid wherever the mask grid has data |
| Scale and offset | i0 * 1.0 + 0.0, edit the numbers to suit |
| Clip to range | clamp(i0, 0.0, 1.0), edit the limits to suit |
Save an algorithm into the folder named at the bottom of the preset menu and it is listed there as a preset of your own.
Building Your Own
Right click the diagram to add nodes: more Grid inputs, Equations, LUTs and Grid outputs. Drag from an output pin to an input pin to link them. Equations take any number of inputs; see Equations for what a formula may contain. If any input of an Equation has no value at a cell, the result has no value there.
A Grid output writes every value linked to it as a band of its file, so one file can hold several results. An algorithm may have several Grid outputs, each writing its own file. See Grid Outputs for the format, cell size, overview and auto write settings.
Colour nodes - Colour LUT, Sun shade and Image - belong in the Imager and cannot be added here.
Grids That Differ
The grids must share a coordinate system and be north up, but they need not cover the same area or have the same cell size. The result covers the area of all the grids feeding it, at the cell size of the finest unless the Grid output sets one. Each grid is sampled where it lies; outside a grid there is no value, so the sum of two grids that only partly overlap has values only where both do.
Tip
Set the Grid output's Smooth option when the output cell is finer than an input's, so the coarse grid is interpolated rather than written as blocks.