如何使用rgdal在R中将EPSG:4326坐标转换为EPSG:3857?

时间:2019-01-09 15:57:10

标签: r coordinates geospatial arcgis rgdal

我设法将在EPSG:4326中投影的坐标集转换为EPSG:3857,但是结果与我得到的坐标不匹配

https://epsg.io/transform#s_srs=4326&t_srs=3857&x=14.5172200&y=46.0658300或直接在ArcGIS中,尽管r中提供的EPSG系统的详细信息(请参见下面的脚本)与GIS软件中的描述相匹配。

我用以下代码尝试过:

library("rgdal", lib.loc="~/Library/R/3.4/library")


orig_coords <- data.frame(lat=c(46.065830, 46.042211, 46.094612), lon=c(14.517220, 14.487756, 14.597046))
coordinates(orig_coords) <- c('lat', 'lon')

#Determine the projection of the lat-long coordinates, by default it is EPSG:4326
proj4string(orig_coords) <- CRS("+init=epsg:4326")
print(summary(orig_coords))

#Convert the coordinates to the used metric system (EPSG:3857)
Metric_coords<-spTransform(orig_coords,CRS("+init=epsg:3857"))
print(summary(Metric_coords))    

正确的坐标是

5790904.807 1616049.538;
5787116.145 1612769.621;
5795523.844 1624935.728;

相反,我得到:

lat - lon;
[1,] 5128025 1633624;
[2,] 5125395 1630236;
[3,] 5131229 1642804;

我找不到问题所在...

1 个答案:

答案 0 :(得分:0)

我认为CRS("+init=epsg:3857")必须用大写字母CRS("+init=EPSG:3857")