This project has moved and is read-only. For the latest updates, please go here.

problem rendering with coordinate transform

Oct 21, 2011 at 12:00 PM

I have a problem when rendering a shape in EPSG32632 to EPSG900913 (google mercator)

this code in VectorLayer.cs give me !notimplementedexception"


 public override void Render(Graphics g, Map map)        {           

if (map.Center == null)             

  throw (new ApplicationException("Cannot render map. View center not specified"));
            g.SmoothingMode = SmoothingMode;           

BoundingBox envelope = map.Envelope; //View to render           

if (CoordinateTransformation != null)            {               


envelope = GeometryTransform.TransformBox(envelope, CoordinateTransformation.MathTransform);               

CoordinateTransformation.MathTransform.Invert();            } ...........



the same if i try to render from  EPSG4326 to EPSG900913

Oct 21, 2011 at 3:11 PM

CoordinateTransformation.MathTransform.Invert();        throw this kind of exception.

Try using this code to build a 4326 to 900913 projection:

            CoordinateSystemFactory csFac = new CoordinateSystemFactory();
            CoordinateTransformationFactory ctFac = new CoordinateTransformationFactory();
            IGeographicCoordinateSystem sourceCs = csFac.CreateGeographicCoordinateSystem(
                "WGS 84",
                new AxisInfo("north", AxisOrientationEnum.North),
                new AxisInfo("east", AxisOrientationEnum.East));

            List<ProjectionParameter> parameters = new List<ProjectionParameter>();
            parameters.Add(new ProjectionParameter("semi_major", 6378137.0));
            parameters.Add(new ProjectionParameter("semi_minor", 6378137.0));
            parameters.Add(new ProjectionParameter("latitude_of_origin", 0.0));
            parameters.Add(new ProjectionParameter("central_meridian", 0.0));
            parameters.Add(new ProjectionParameter("scale_factor", 1.0));
            parameters.Add(new ProjectionParameter("false_easting", 0.0));
            parameters.Add(new ProjectionParameter("false_northing", 0.0));
            IProjection projection = csFac.CreateProjection("Google Mercator", "mercator_1sp", parameters);
            IProjectedCoordinateSystem targetCs = csFac.CreateProjectedCoordinateSystem(
                "Google Mercator",
                new AxisInfo("East", AxisOrientationEnum.East),
                new AxisInfo("North", AxisOrientationEnum.North));
            return ctFac.CreateFromCoordinateSystems(sourceCs, targetCs);

Oct 21, 2011 at 6:46 PM


Proj4Net have problem with some projections and inverting them.

In the latest trunk-version of SharpMap you can also se the ReverseCoordinateTransformation on the Layer.


Set transformation EPSG32632 to EPSG900913  for CoordinatTransformation and 

EPSG900913 to EPSG32632 av Reverse Coordinate Transformation