# IGRID

## Purpose:

Grids irregular XYZ data to a uniform grid using the inverse distance
method.

## Syntax:

IGRID(x, y, z, gridsize, interp, weights,
radius)

x |
- |
A series, the X or horizontal range. |

y |
- |
A series, the Y or vertical
range. |

z |
- |
A series, the Z or height data. |

gridsize |
- |
Optional. An integer or series, the size of
output grid. Defaults to **sqrt(length(x))**. |

interp |
- |
Optional. An integer, the cubic spline smoothing
factor. Defaults to 1 (no smoothing). |

weights |
- |
Optional. A series, the weights of distance
function. Defaults to {0, 0, 1, 1, 1}. |

radius |
- |
Optional. A real, the maximum radius to include
in the interpolation. Defaults to -1, all. |

## Returns:

An array.

## Example:

x = grand(100, 1)*2 - 1;

y = grand(100, 1)*2 - 1;

z = cos(x*y);

xyz = igrid(x, y, z);

Grids the function cos(x*y) over the
range -1 to 1 with an interpolated grid of 11x11.

## Example:

xyz2 = igrid(x, y, z, 20)

Same as above but the interpolated grid is 20x20.

## Example:

xyz2 = igrid(x[..], y[..], z[..], {20, 30}, 3)

Same as above but the interpolated grid is 20x30 and the surface is
further interpolated by a factor of 3 using cubic spline interpolation.

## Example:

IGRID also accepts a single XYZ series as input:

xyzser = xyz(x, y, z)

xyz3 = igrid(xyzser)

Same as first example.

xyz3 = igrid(xyzser, 20)

Same as second example.

xyz3 = igrid(xyzser, {20, 30}, 3)

Same as third example.

xyz4 = igrid(xyzser, {20, 30}, 3, {0, 1})

Same as above except the classical inverse squared distance weighting
function is used instead of the default.

## Remarks:

IGRID uses INVDISTANCE,
the inverse distance method of gridding irregularly spaced data.

If GRIDSIZE is a series, the first element specifies the output number
of columns and the second element specifies the output number of rows.

The optional WEIGHTS series specifies the weighting of
the radius terms:

{r^-1, r^-2, r^-3, r^-4, ...}.

The default of {0, 0, 1, 1, 1}
specifies a linear combination of r^{-3}
+ r^{-4}
+ r^{-5}
terms and {0, 1} specifies
the classical inverse squared distance weighting function. See INVDISTANCE
for algorithmic details.

## See Also:

INTERP2

INVDISTANCE

PLOT3D

SPLINE2