Different coordinate reprojection using builtin CS webmercator and CS from SRID

Topics: General Topics
Mar 23 at 3:13 PM
Edited Mar 23 at 3:15 PM
Hello

First of all thanks for this great component. I'm having great fun making a GIS app for public lighting purposes.

This could be another thread about how to reproject on the fly but I think it's more complex. The thing is that when reprojecting I'm getting differents coordinates using the builtin webmercator projection or the WKT from SpatialRefSys.xml.

My background tiles are in 3857 (webmercator) and my datasources in 25829 (ETRS89 29N)

This code DOESN'T WORK OK, coordinates seems to be about 50km to the south:
Dim ctFact As New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory
Dim css As ProjNet.CoordinateSystemServices = New ProjNet.CoordinateSystemServices(New ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.ASCII), New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(), SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems())

CoordTrans = ctFact.CreateFromCoordinateSystems(css.GetCoordinateSystem(25829), css.GetCoordinateSystem(3857))
RevCoordTrans = ctFact.CreateFromCoordinateSystems(css.GetCoordinateSystem(3857), css.GetCoordinateSystem(25829))
On the other hand, using the same code except you use the builtin mercator, WORKS FLAWLESSLY:
Dim ctFact As New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory
Dim css As ProjNet.CoordinateSystemServices = New ProjNet.CoordinateSystemServices(New ProjNet.CoordinateSystems.CoordinateSystemFactory(System.Text.Encoding.ASCII), New ProjNet.CoordinateSystems.Transformations.CoordinateTransformationFactory(), SharpMap.Converters.WellKnownText.SpatialReference.GetAllReferenceSystems())


CoordTrans = ctFact.CreateFromCoordinateSystems(css.GetCoordinateSystem(25829), ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator)
RevCoordTrans = ctFact.CreateFromCoordinateSystems(ProjNet.CoordinateSystems.ProjectedCoordinateSystem.WebMercator, css.GetCoordinateSystem(25829))
I think both ways to generate the webmercator coordinate system should end with the same result so the reprojection should work in both cases., but it's ok.

Regards.
Coordinator
Mar 29 at 7:38 AM
You are right.
Have you tried to update the WKT for EPSG:3857 with the one gcapnias came up with in this thread:
http://projnet.codeplex.com/discussions/352813
PROJCS["Google Mercator",
    GEOGCS["WGS 84",
        DATUM["World Geodetic System 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","9102"]],
        AXIS["north",NORTH],
        AXIS["east",EAST]],
    PROJECTION["Mercator_1SP"],
    PARAMETER["semi_major",6378137],
    PARAMETER["semi_minor",6378137],
    PARAMETER["latitude_of_origin",0],
    PARAMETER["central_meridian",0],
    PARAMETER["scale_factor",1],
    PARAMETER["false_easting",0],
    PARAMETER["false_northing",0],
    UNIT["metre",1,AUTHORITY["EPSG","9001"]],
    AXIS["East",EAST],
    AXIS["North",NORTH]
]
Apr 11 at 8:55 PM
Solved updating the WKT in SpatialRefSys.xml with the one from gcapnias. Now it reprojects ok.
Thanks for your support Felix.

Regards.