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?