1

I don't have much experience with GIS.

Here's are my projections defintion:

        private Dictionary<CoordinateSystemStrings, string> CoordinateSystemStringDictionary = new Dictionary<CoordinateSystemStrings, string>()
    {
        {CoordinateSystemStrings.EPSG2154, "PROJCS[\"RGF93 / Lambert-93\",GEOGCS[\"RGF93\",DATUM[\"Reseau_Geodesique_Francais_1993\",SPHEROID[\"GRS 1980\",6378137,298.257222101,AUTHORITY[\"EPSG\",\"7019\"]],TOWGS84[0,0,0,0,0,0,0],AUTHORITY[\"EPSG\",\"6171\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4171\"]],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],PROJECTION[\"Lambert_Conformal_Conic_2SP\"],PARAMETER[\"standard_parallel_1\",49],PARAMETER[\"standard_parallel_2\",44],PARAMETER[\"latitude_of_origin\",46.5],PARAMETER[\"central_meridian\",3],PARAMETER[\"false_easting\",700000],PARAMETER[\"false_northing\",6600000],AUTHORITY[\"EPSG\",\"2154\"],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH]]"},
        {CoordinateSystemStrings.EPSG3857, "PROJCS[\"WGS 84 / Pseudo-Mercator\",GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.0174532925199433,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]],PROJECTION[\"Mercator_1SP\"],PARAMETER[\"central_meridian\",0],PARAMETER[\"scale_factor\",1],PARAMETER[\"false_easting\",0],PARAMETER[\"false_northing\",0],UNIT[\"metre\",1,AUTHORITY[\"EPSG\",\"9001\"]],AXIS[\"X\",EAST],AXIS[\"Y\",NORTH],EXTENSION[\"PROJ4\",\"+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +wktext +no_defs\"],AUTHORITY[\"EPSG\",\"3857\"]]"},
        {CoordinateSystemStrings.WGS84, "GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.0174532925199433]]"}
    };

And here is the method I use to apply them:

        public Coordinate[] Transform(Coordinate[] points, CoordinateSystemStrings sourceCoordinateSystemString, CoordinateSystemStrings targetCoordinateSystemString)
    {
        CoordinateSystemFactory coordinateSystemFactory = new CoordinateSystemFactory();
        ICoordinateSystem sourceCoordinateSystem = coordinateSystemFactory.CreateFromWkt(this.CoordinateSystemStringDictionary[sourceCoordinateSystemString]);
        ICoordinateSystem targetCoordinateSystem = coordinateSystemFactory.CreateFromWkt(this.CoordinateSystemStringDictionary[targetCoordinateSystemString]);
        ICoordinateTransformation trans = (new CoordinateTransformationFactory()).CreateFromCoordinateSystems(sourceCoordinateSystem, targetCoordinateSystem);

        return trans.MathTransform.TransformList(points).ToArray();
    }

In different calls to this method I do the following transformations

  • WSG84 to EPSG:2154 : OK
  • EPSG:2154 to WSG84 : OK
  • EPSG:2154 to EPSG:3857 : Error.

Exception message:

{"Missing projection parameter 'latitude_of_origin'\nIt is also not defined as 'latitude_of_center'.\r\nParameter name: parameterName"}

I have a feeling like my EPSG:3857 string is not right or I am missing something.

  • List item
1

Comparing the WKT string with ProjectedCoordinateSystem.WebMercator.WKT, it misses the part PARAMETER["latitude_of_origin", 0], which you could insert right after the PROJECTION tag. After that, the transformation should work.

It might be better to use ProjectedCoordinateSystem.WebMercator directly if that's the coordinate system you are looking for. There is an interesting article discuss how earlier definitions of the 3857 projection might be inaccurate.

  • Thank you. We go through EPSG:2154 because we need to do some math there that require precise distange. Also thank you for the article, it is quite likely that we are experiencing the "20 km" shift on Google/Bing (though we mostly use OSM). – TTT Nov 13 '15 at 9:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.