R - 使用 rgdal 包转换 UTM 坐标的问题

R - Problems with converting UTM coordinates with the rgdal package

我的任务是将大量 UTM 坐标(33 区)转换为经纬度 (WGS84) 坐标。这些位置应该位于挪威边境附近。我尝试使用 rgdal 包

转换 R 中的坐标
#extracting some examples from data set

lat <- c(7790281, 7726438, 7266202, 7259480, 7271802)
long <- c(1053817, 1054025, 451754, 475228, 462235)
df <- data.frame(lat, long)

#converting from UTM33 to WGS84

library(rgdal)
tmp <- data.frame(coords.x = df$lat, coords.y = df$long)
coordinates(tmp) <-c("coords.x","coords.y")
proj4string(tmp) <- CRS("+proj=utm +zone=33 ellps=WGS84") #UTM zone 33
CRS.new <- CRS("+init=epsg:4326") # WGS84
coords <- spTransform(tmp,CRS.new)

#making a dataframe out of coordinates
coords <- data.frame(lat=coords@coords[,1], long=coords@coords[,2])

这会产生

       lat     long
1 69.19936 5.840162
2 68.92219 5.857922
3 66.55129 2.585804
4 66.52160 2.721701
5 66.58242 2.644578

但是,当使用在线转换工具 (http://www.rcn.montana.edu/resources/converter.aspx) 转换坐标时,我得到以下不同的结果

  lat.corr long.corr
1 69.63112  29.37223
2 69.07562  29.00514
3 65.51455  13.95675
4 65.45688  14.46554
5 65.56618  14.18178

在同一张地图上绘制两个数据集时,可以清楚地看到用 rgdal 转换的点错位了。

Map

如果我试图了解问题所在,但经过数小时的考虑和研究,我仍然无法找到问题所在。如果能帮忙找出问题所在,我们将不胜感激!

编辑:它可能与跨越 UTM 区域边界的东坐标有关。会不会是 rgdal 无法应对?

我猜你在

中混合了纬度和经度
tmp <- data.frame(coords.x = df$lat, coords.y = df$long)

应该是:

tmp <- data.frame(coords.x = df$lon, coords.y = df$lat)

你得到:

> (coords <- data.frame(lon=coords@coords[,1], lat=coords@coords[,2]))
   lon     lat
1 29.37172 69.63114
2 29.00472 69.07564
3 13.95675 65.51455
4 14.46554 65.45688
5 14.18178 65.56618