Please can someone help me convert a point in WGS1984 to OSGB1936, I have followed all the documentation (or so i think…) and yet have not made any headway into this problem. This is my code :
Type factoryType = Type.GetTypeFromProgID("esriGeometry.SpatialReferenceEnvironment");
System.Object obj = Activator.CreateInstance(factoryType);
ISpatialReferenceFactory3 spacialReferenceFactory3 = obj as ISpatialReferenceFactory3;
// Create Transformation from WGS84 to OSGB86
IGeoTransformation geoTrans = spacialReferenceFactory3.CreateGeoTransformation((int)esriSRGeoTransformationType.esriSRGeoTransformation_OSGB1936_To_WGS1984Petrol) as IGeoTransformation;
ISpatialReference fromSpatialReference;
ISpatialReference toSpatialReference;
geoTrans.GetSpatialReferences(out fromSpatialReference, out toSpatialReference);
IGeometry5 geometry;
IPoint point = new PointClass();
point.PutCoords(51.465615, -3.159875);
geometry = point as IGeometry5;
geometry.SpatialReference = toSpatialReference;
geometry.ProjectEx(fromSpatialReference, esriTransformDirection.esriTransformForward, geoTrans, false, 0.0, 0.0);
point = new PointClass();
point = geometry as IPoint;
My point is being returned from the Geometry object as 51.46200954514034, -3.1549783406850165. I have tried using the reverse transformation as specified in geometry.ProjectEx()
, and all i get is the same X and Y as the original point. I have also tried different combinations of reverse / forward and also swapping the fromSpatialReference
and toSpatialReference
.
Best Answer
This prints:
319524.804848596 174709.885049006
.