GPS transformation

Topics: Algorithms, SharpMap v0.9 / v1.x
Apr 1, 2008 at 8:15 PM
Hi,

I can't transforms GPS coordinates to ED 1950 31N. Could you help me please?
I wrote:

SharpMap.CoordinateSystems.CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();
GeoAPI.CoordinateSystems.IGeographicCoordinateSystem gcs = SharpMap.CoordinateSystems.GeographicCoordinateSystem.WGS84;
GeoAPI.CoordinateSystems.IProjectedCoordinateSystem coordsys = CreateUtmProjection(31);
GeoAPI.CoordinateSystems.Transformations.ICoordinateTransformation trans = new SharpMap.CoordinateSystems.Transformations.CoordinateTransformationFactory().CreateFromCoordinateSystems(coordsys, gcs);
GeoAPI.Geometries.IPoint pnt1 = SharpMap.CoordinateSystems.Transformations.GeometryTransform.TransformPoint(SharpMap.Converters.Geometries.GeometryFactory.CreatePoint(dcLon, dcLat), trans.MathTransform);


where:
private IProjectedCoordinateSystem CreateUtmProjection(int utmZone)
{
CoordinateSystemFactory cFac = new SharpMap.CoordinateSystems.CoordinateSystemFactory();

//Create geographic coordinate system based on the WGS84 datum
IEllipsoid ellipsoid = cFac.CreateFlattenedSphere("WGS 84", 6378137, 298.257223563, LinearUnit.Metre);
IHorizontalDatum datum = cFac.CreateHorizontalDatum("WGS1984", DatumType.HDGeocentric, ellipsoid, null);
IGeographicCoordinateSystem gcs = cFac.CreateGeographicCoordinateSystem("WGS 84", AngularUnit.Degrees, datum, PrimeMeridian.Greenwich, new AxisInfo("Lon", AxisOrientationEnum.East),
new AxisInfo("Lat", AxisOrientationEnum.North));

//Create UTM projection
List<ProjectionParameter> parameters = new List<ProjectionParameter>(5);
parameters.Add(new ProjectionParameter("latitudeoforigin", 0));
parameters.Add(new ProjectionParameter("central_meridian", -183 + 6 * utmZone));
parameters.Add(new ProjectionParameter("scale_factor", 0.9996));
parameters.Add(new ProjectionParameter("false_easting", 500000));
parameters.Add(new ProjectionParameter("false_northing", 0.0));
IProjection projection = cFac.CreateProjection("Transverse Mercator", "Transverse_Mercator", parameters);

return cFac.CreateProjectedCoordinateSystem("WGS 84 / UTM zone " + utmZone.ToString() + "N", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
}
Developer
Apr 1, 2008 at 9:18 PM
Do you get an exception or is the transformed coordinate not correct?

Paul.
Apr 2, 2008 at 8:16 AM
1. I don't see ED50 anywhere in there (as far as I can tell you create a transformation from geographic WGS84 to UTM WGS84.
2. I don't see a datum transformation in your code either. You need to know and set the 7-parameter TOWGS84 Molodensky input for your area. This changes from area to area, and from country to country (based on local definitions). Ask your national ordinance survey.