If desired, a dimension can have an associated variable called the coordinate variable (CV). This is a vector which defines a piecewise-linear mapping from subscript to physical dimension.
CVs are convenient when each array dimension maps to a single physical dimension.
However, the relationship between array dimensions and physical dimensions may be more complex.
Consider the example of
a satellite image with dimensions line (row) and pixel (column).
The physical dimension latitude depends on both array dimensions
(line and pixel).
There is a matrix (with the same line and pixel dimensions as the image)
giving the latitude at each point.
There is another similar longitude matrix.
These two matrices define piecewise-bilinear mappings from line/pixel space to
latitude/longitude space.
The task of warping the image to latitude/longitude space is essentially that of defining
mappings from latitude/longitude space to line/pixel space
i.e. the inverses of the given mappings.
This can be done using the NAP functions
invert_grid and invert_grid_no_trim.
Data in a continuous space with two or more dimensions can be either gridded or scattered. NAP's data-model (with continuous subscripts, coordinate variables, etc.) facilitates the processing of gridded data.
Let us consider the case of two dimensions i.e. matrices. Two-dimensional gridded data is aligned in rows and columns, whereas scattered data is not. The following examples are intended to illustrate the difference between scattered and gridded 2D data.
Note that the data are not aligned in rows and columns.
| • | |||||||||
| • | • | ||||||||
| • | |||||||||
| • | |||||||||
| • | |||||||||
| • | |||||||||
| • | |||||||||
The following example has the grid in black. The blue point is not on the grid and has non-integer subscript values (2.1, 1.6). The coordinate variables are latitude and longitude.
| column | 0 | 1 | 1.6 | 2 | 3 | 4 | ||
| longitude | 30°E | 40°E | 52°E | 60°E | 65°E | 75°E | ||
| row | latitude | |||||||
| 0 | 30°N | • | • | • | • | • | ||
| 1 | 25°N | • | • | • | • | • | ||
| 2 | 10°N | • | • | • | • | • | ||
| 2.1 | 8°N | • | ||||||
| 3 | 10°S | • | • | • | • | • | ||
The following example is similar to that above. However four grid points are missing. These are shown in red.
| column | 0 | 1 | 1.6 | 2 | 3 | 4 | ||
| longitude | 30°E | 40°E | 52°E | 60°E | 65°E | 75°E | ||
| row | latitude | |||||||
| 0 | 30°N | • | • | • | • | • | ||
| 1 | 25°N | • | • | • | • | • | ||
| 2 | 10°N | • | • | • | • | • | ||
| 2.1 | 8°N | • | ||||||
| 3 | 10°S | • | • | • | • | • | ||
The missing points are treated as if they did not exist, as shown in the following:
| column | 0 | 1 | 1.6 | 2 | 3 | 4 | ||
| longitude | 30°E | 40°E | 52°E | 60°E | 65°E | 75°E | ||
| row | latitude | |||||||
| 0 | 30°N | • | • | • | • | |||
| 1 | 25°N | • | • | • | • | • | ||
| 2 | 10°N | • | • | • | ||||
| 2.1 | 8°N | • | ||||||
| 3 | 10°S | • | • | • | • | |||
It would be possible to represent scattered data by a grid with many missing points. In the extreme, each scattered point would have its own row and its own column. There would be only one non-missing point in each row. There would be only one non-missing point in each column. Of course this would be very inefficient for a matrix of significant size.
Function
scattered2grid
interpolates scattered data onto a grid.