2

enter image description here

When I transform coordinates from LV95 to WGS84 using the R function spTransform, the resulting WGS84 coordinates are approx. 170 m off in direction North-East, i.e. they are incorrect.

Here is my code example:

library(rgdal)

conversion function:

myConvert_LV95_to_WGS84 = function(myCoords_LV95) {
    df = data.frame(myCoords_LV95)
    coordinates(df) = ~ X1 + X2
    df@proj4string = CRS("+init=epsg:2056")
    myCoords_WGS84 = spTransform(df, CRS("+init=epsg:4326"))
    myCoords_WGS84@coords
}

Input sample LV95 coordinates:

coords_LV95 = matrix(
    c(2726201,1202028,
      2726148,1202001,
      2726148,1201995),
      nrow=3,
      ncol=2,
      byrow = TRUE
)

coords_WGS84 = myConvert_LV95_to_WGS84(coords_LV95) 

Resulting WGS84 coordinates, which are incorrect:

coords_WGS84
        X1       X2
1 9.097946 46.95864
2 9.097242 46.95841
3 9.097241 46.95836

The correct WGS84 coordinates would be (calculated from swisstopo's approximation formula):

         [,1]     [,2]
[1,] 9.096741 46.95733
[2,] 9.096037 46.95710
[3,] 9.096035 46.95704

The prj-file for the input coordinates:

> PROJCS["CH1903+_LV95",GEOGCS["GCS_CH1903+",DATUM["D_CH1903+",SPHEROID["Bessel_1841",6377397.155,299.1528128]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Hotine_Oblique_Mercator_Azimuth_Center"],PARAMETER["False_Easting",2600000.0],PARAMETER["False_Northing",1200000.0],PARAMETER["Scale_Factor",1.0],PARAMETER["Azimuth",90.0],PARAMETER["Longitude_Of_Center",7.439583333333333],PARAMETER["Latitude_Of_Center",46.95240555555556],UNIT["Meter",1.0]],VERTCS["LN_1902",VDATUM["Landesnivellement_1902"],PARAMETER["Vertical_Shift",0.0],PARAMETER["Direction",1.0],UNIT["Meter",1.0]]

What am I doing wrong?

9
  • Your correct output examples are three times the same values. Transforming your LV95 coordinates example, I get three slightly different vlaues (last 3 digits), see: i.sstatic.net/ZMS4f.png - your problem might be due to a rounding error?
    – Babel
    Commented Sep 15, 2021 at 14:25
  • Thank you very much for your quick reply and hints! I added the correct WGS84 coordinates above (sorry for that). I also added a screen shot, showing the distance between the correct (green) and wrong (red) lines (approx. 170m), quite big for a rounding error.
    – Guido Kehl
    Commented Sep 15, 2021 at 15:41
  • Question: your results are quite precise. Did you produce them with my R-code above or did you use your own transformation utility? Thank you!
    – Guido Kehl
    Commented Sep 15, 2021 at 15:43
  • I used QGIS for transformation
    – Babel
    Commented Sep 15, 2021 at 15:44
  • 2
    This smells like a datum conversion issue, but I am not familiar with R, so I can't say for sure. I notice that the spTransform docs mention that the behaviour w.r.t. datums has changed. Commented Sep 15, 2021 at 17:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.