GridInterpolator Class

Class for interpolating values from a grid.

Interpolation is performed in two steps, first step is calculation of fractional indices and second step is interpolation based on fractional indices.

Fractional indices are calculated by calling one of the *2Jk methods. Values are interpolated by calling the Interpolate(Single, Double, Double, Single) method with the fractional indices.

Calculating fractional indices involves various map projection calculations and can be computational expensive. The fractional indices are meant to be stored in case they are to be reused.

By setting up reprojection, using one of the SetupReprojection methods, you can specify a target projection different from the grid projection. Then interpolation point coordinates provided in the *2Jk methods (as well Xy, Proj and Geo version) are assumed to be in that target map projection, and reprojection from the target projection to the grid projection will be performed before calculating fractional indices.

Definition

Namespace: DHI.Projections
Assembly: DHI.Projections (in DHI.Projections.dll) Version: 24.0.0.0 (11.1.1.1111)
C#
public class GridInterpolator
Inheritance
Object    GridInterpolator

Remarks

The range of the fractional indices varies depending on wether the grid is element/cell based or node based.
  • For a 3 x 2 element/cell based grid, (j,k) is in the range [0;3] x [0;2].
  • For a 3 x 2 node based grid, (j,k) is in the range [0;2] x [0;1].

Constructors

GridInterpolator Create a new object

Properties

DoInterpolate Bool specifying whether to interpolate (true) or take the closest value (false, default)
Reprojector Reprojector used when converting between map projections.

You can use this to set datum shift parameters. When no reprojection is specified this will be null.

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Geo2Jk Convert coordinates from projection easting-northing coordinates to fractional indices in the source grid. The fractional indices can be used directly in the Interpolate(Single, Double, Double, Single) method.

For a 3 x 2 element/cell based grid, (j,k) is in the range [0;3] x [0;2].

For a 3 x 2 node based grid, (j,k) is in the range [0;2] x [0;1].

GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
Interpolate Interpolate in the source array at relative/fractional index (jRel,kRel), using the undefinedValue as an undefined value/delete value that is not taken into account when interpolating.
IsInside Check if fractional index is inside grid.
Proj2Jk Convert coordinates from projection easting-northing coordinates to fractional indices in the source grid. The fractional indices can be used directly in the Interpolate(Single, Double, Double, Single) method.

For a 3 x 2 element/cell based grid, (j,k) is in the range [0;3] x [0;2].

For a 3 x 2 node based grid, (j,k) is in the range [0;2] x [0;1].

SetupReprojection(Cartography) Enable reprojection, i.e. conversion from a target coordinate system to the coordinate system of the grid.

The returned Reprojector object can be used for specifying datum shift parameters. The Reprojector is set up using the grid projection as the source projection and the projection provided in this method as the target projection. It must always have the convertion type Geo2Geo handling datum shifts only.

SetupReprojection(Reprojector, Cartography) Enable reprojection, i.e. conversion from a target coordinate system to the coordinate system of the grid.

The Reprojector object is used for datum shift conversions only. The Reprojector must be set up using the grid projection as the source projection and the projection provided in this method as the target projection. It must always have the convertion type Geo2Geo, i.e. handling datum shifts only.

ToStringReturns a string that represents the current object.
(Inherited from Object)
Xy2Jk Convert coordinates from local grid x-y coordinates to fractional indices in the source grid. The fractional indices can be used directly in the Interpolate(Single, Double, Double, Single) method.

For a 3 x 2 element/cell based grid, (j,k) is in the range [0;3] x [0;2].

For a 3 x 2 node based grid, (j,k) is in the range [0;2] x [0;1].

See Also