CodePlexProject Hosting for Open Source Software

First create a CoordinateTransformationFactory:

CoordinateTransformationFactory ctfac = new CoordinateTransformationFactory();

Then create the transformation instance:

ICoordinateTransformation trans = ctfac.CreateFromCoordinateSystems(fromCS, toCS);

All transformations are done on double arrays, where the first value is primary axis (X/East/Latitude) and the second the secondary (Y/North/Longitude). You can provide an optional third value (Z/Height), which can change if a datum transformation occurs* during the transform.

Example:

double[] fromPoint = new double[] { 120, -3 }; double[] toPoint = trans.MathTransform.Transform(fromPoint);

If you want to transform back again, create an inversed transformation:

IMathTransform inversedTransform = trans.MathTransform.Inverse(); double[] point = inversedTransform.Transform(toPoint);

*Note that no datum transformation is applied if the coordinate systems doesn't have a ToWGS84 parameter defined.

Last edited Oct 4, 2007 at 6:02 AM by SharpGIS, version 2

I'm trying a transaformation tha implies datum transformation. "*Note that no datum transformation is applied if the coordinate systems doesn't have a ToWGS84 parameter defined" exactly what this mean?

I think that this information is incorrect: "primary axis (X/East/Latitude) and the second the secondary (Y/North/Longitude)".

Did a transformation from GCS WGS84 to a PCS WGS84 (22S) and noted that the input must be the usual lng/lat (not lat/lng) to get the correct X/Y values.

Did a transformation from GCS WGS84 to a PCS WGS84 (22S) and noted that the input must be the usual lng/lat (not lat/lng) to get the correct X/Y values.