Reprojector Class

The Reprojector class handles conversion from a source map projection to a target map projection. The conversion can be performed with or without height. The conversion automatically handles datum (ellipsoid) conversions, and can also perform datum shifts.

The TypeOfConversion defines type of coordinates used in conversion.

The reprojection conversion from source map projection to target map projection coordinates works as follows:

  • Source projection coordinates (east, north) are converted to source geographic coordinates (lon, lat)
  • Source geographic coordinates (lon, lat, height) are converted to source Eucledian datum coordinates (x,y,z)
  • Datum shift is applied, if specified, to target Eucledian datum coordinates (x,y,z)
  • Target Eucledian datum coordinates (x,y,z) are converted to target geographic coordinates (lon, lat, height)
  • Target geographic coordinates (lon, lat) are converted to target projection coordinates (east, north)
When datum shift parameters are not specified, and the datums (ellipsoids) of the source and the target are identical, the three middel steps are skipped. The three middle steps can also be bypassed by setting explicitly the BypassDatumConversions property to false. That will give incorrect results, however especially some graphical tools does this for performance reasons: Visually the results will look ok as long as all data are defined in projections sharing the same datum (ellipsoid), and all visualization take place in target projection - if data are defined in projections using different datums (ellipsoids), errors will occur.

The datum shift works in a two step process:

  • Source datum shift conversion is applied, if specified
  • Target datum shift inverse conversion is applied, if specified

It is possible to specify datum shift parameters for as well the source as the target map projection.

If datum shift parameters directly from source to target is known, this must be set as the source datum shift parameters.

If datum shift parameters directly from target to source is known, this must be set as the target datum shift parameters.

If datum shift parameters is known from both source and target to a common datum, both set of parameters must be specified. Then a reprojection will first convert from source datum to common datum, and then from common datum to target datum by an inverse datum shift operation.

Definition

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

Example

// Projection strings are truncated due to their lenghts. string utm20NNad1927 = @"PROJCS[""NAD_1927_UTM_Zone_20N"", ... string utm20NWgs84 = @"PROJCS[""WGS_1984_UTM_Zone_20N"", ... // Create reprojector. Reprojector reprojector = new Reprojector(utm20NNad1927, utm20NWgs84); // Conversion from projection-to-projection coordinates, no height x = 35000; y = 6000000; reprojector.Convert(ref x, ref y); // Converting from projection-to-geographical coordiantes, including height reprojector.TypeOfConversion = Reprojector.ConversionType.Proj2Geo; x = 35000; y = 6000000; h = 100; reprojector.Convert(ref x, ref y, ref h);

Constructors

Reprojector(String, String) Create a new reprojector object, converting from source to target as specified in the arguments.
Reprojector(String, String, Boolean) Create a new reprojector object, converting from source to target as specified in the arguments.

Properties

DoDatumConversions Flag informing whether datum conversions are enabled or disabled.

Datum conversions are by default enabled, and disabled only if the datums (ellipsoids) of the source and target are the same, AND no datum shifts has been specified.

Datum conversions can be explicitly bypassed by calling BypassDatumConversions.

The flag can be reset to its default value by calling ResetDoDatumConversions.

Call to any of the SetDatumShiftParameters or the SetNoDatumShift(ReprojectorSide) methods will also revert this flag to its default value.

ProjectionStringSource Target Map Projection
ProjectionStringTarget Source Map Projection
TypeOfConversion Type of conversion. Default is Proj2Proj.

Methods

BypassDatumConversions Explicitly bypass datum conversions, setting the DoDatumConversions to false.
Convert(Double, Double) Converts a point (x, y) from the source map projection to the target map projection.
Convert(Double, Double, Double) Converts a point (x, y, h) from the source map projection to the target map projection.
DatumShift Converts a point in Euclidean coordinates (x, y, z) relative to the source datum center to Euclidean coordinates relative to the target datum center.

This is done in a two step process. First the coordinates are converted from the source datum center to an arbitrary geocentric Euclidean space, and from there it's converted to the target datum center.

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetTypeGets the Type of the current instance.
(Inherited from Object)
InvConvert(Double, Double) Inverse conversion, converts a point (x, y) from the target map projection to the source map projection.
InvConvert(Double, Double, Double) Inverse conversion, converts a point (x, y, h) from the target map projection to the source map projection.
InvDatumShift Inverse conversion, converts a point in Euclidean coordinates (x, y, z) relative to the target datum center to Euclidean coordinates relative to the source datum center.

This is done in a two step process. First the coordinates are converted from the target datum center to an arbitrary geocentric Euclidean space, and from there it's converted to the source datum center.

InvertOrder Invert the order of the conversion, by swapping the source and the target map projection, including any datum shift parameters.

Also the TypeOfConversion will be inverted, i.e. a type of Proj2Geo will be changed to Geo2Proj and vice versa.

ResetDoDatumConversions Reset the DoDatumConversions flag to its default value.
SetDatumShiftParameters(ReprojectorSide, Double, Double, Double) Sets the 3-parameter datum shift parameters of either the source or the target map projection.

This call will reset the BypassDatumConversions flag

SetDatumShiftParameters(ReprojectorSide, Double, Double, Double, Double, Double, Double, Double) Sets the 7-parameter datum shift parameters of either the source or the target map projection.
SetNoDatumShift Disable datum shift calculations for either the source or the target.

This call will reset the BypassDatumConversions flag

ToStringReturns a string that represents the current object.
(Inherited from Object)

See Also