Click or drag to resize

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.

Inheritance Hierarchy
SystemObject
  DHI.ProjectionsGridInterpolator

Namespace:  DHI.Projections
Assembly:  DHI.Projections (in DHI.Projections.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public class GridInterpolator

The GridInterpolator type exposes the following members.

Constructors
  NameDescription
Public methodGridInterpolator
Create a new object
Top
Properties
  NameDescription
Public propertyDoInterpolate
Bool specifying whether to interpolate (true) or take the closest value (false, default)
Public propertyReprojector
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.

Top
Methods
  NameDescription
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodGeo2Jk
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].

Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInterpolate
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.
Public methodIsInside
Check if fractional index is inside grid.
Public methodProj2Jk
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].

Public methodSetupReprojection(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.

Public methodSetupReprojection(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.

Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodXy2Jk
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].

Top
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].
See Also