Cannot Convert Coordinatesystem from Transverse Mercator To Mercator

Oct 26, 2006 at 4:51 AM
I see Example " Overlaying Local Live maps with your own map-data " then I try to convert my CS to Mercator by funtion Transform2Mercator but error message "Geographic coordinate system was null" in line "IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Mercator", source as IGeographicCoordinateSystem, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));" my CS is "PROJCS"Indian_1975_UTM_Zone_47N",GEOGCS["GCS_Indian_1975",DATUM["D_Indian_1975",SPHEROID["Everest_1830",6377276.345,300.8017]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",99.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]"
what wrong in my code ?
Developer
Oct 26, 2006 at 6:11 AM
If you source is not of type IGeographicCoordinateSystem, this will return null: "source as IGeographicCoordinateSystem".
I guess in your case the source will be a projected coordinate system.

Furtermore you should be aware that since you don't specify a conversion from DIndian1975 to WGS84 (which Local Live uses), your accuracy will be very poor.
Oct 26, 2006 at 8:52 AM
thank with your answer
I try to convert from indian 1975 to wgs84 but my layer was disappear !!!
Can u suggest me?
this is my code
'public static SharpMap.CoordinateSystems.Transformations.ICoordinateTransformation TransformIndian1975ToWGS84(ICoordinateSystem source)
{
CoordinateSystemFactory cFac = new CoordinateSystemFactory();
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));
System.Collections.Generic.List<ProjectionParameter> parameters = new System.Collections.Generic.List<ProjectionParameter>(5);
parameters.Add(new ProjectionParameter("latitudeoforigin", 0));
parameters.Add(new ProjectionParameter("central_meridian", 99));
parameters.Add(new ProjectionParameter("false_easting", 500000));
parameters.Add(new ProjectionParameter("false_northing", 0));
parameters.Add(new ProjectionParameter("Factor", 0.9996));
IProjection projection = cFac.CreateProjection("Mercator", "Mercator_2SP", parameters);
IProjectedCoordinateSystem coordsys = cFac.CreateProjectedCoordinateSystem("Mercator", gcs, projection, LinearUnit.Metre, new AxisInfo("East", AxisOrientationEnum.East), new AxisInfo("North", AxisOrientationEnum.North));
return new CoordinateTransformationFactory().CreateFromCoordinateSystems(source,coordsys);

}'