如何将经度/纬度转换为UTM?R.rgdal,sp

Pan*_*ito 1 r rgdal r-sp

我的数据是以度、分和秒的形式进行纬度和经度投影。这已经以文本形式存储(character-class,忽略row.names)。

\n\n
> pasaporte\n         Latitud        Longitud\n4  13\xc2\xb050\xc2\xa852" sur 73\xc2\xb045\xc2\xa812" oeste\n36    13\xc2\xb001\xc2\xa8 sur    75\xc2\xb005\xc2\xa8 oeste\n46 13\xc2\xb009\xc2\xa826" sur 74\xc2\xb013\xc2\xa822" oeste\n
Run Code Online (Sandbox Code Playgroud)\n\n

通过邮件列表中提供的答案,我已将数据转换为十进制形式......

\n\n
> pasaporte\n    Latitud Longitud\n4  13.84778 73.75333\n36 13.01667 75.08333\n46 13.15722 74.22278\n
Run Code Online (Sandbox Code Playgroud)\n\n

之后,我将 转换data.frameSpatialPoints对象。

\n\n
xy <- data.frame(cbind(round(pasaporte[, \'Longitud\'], 5), round(pasaporte[, \'Latitud\'], 5))) #Rounded the decimals out of doubt of it interfering later\nxy <- SpatialPoints(coords = xy,\n                proj4string =  CRS(\'+proj=longlat +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs\'))\n
Run Code Online (Sandbox Code Playgroud)\n\n

然后继续通过以下方式变换投影spTransform

\n\n
xy_utm <- spTransform(xy, CRS(\'+proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84:0,0,0\'))\n
Run Code Online (Sandbox Code Playgroud)\n\n

我已经使用此网站转换了示例中的第一个坐标(由于坐标指的是南和西,因此请舒尔提供负值),并提供以下坐标:633726.46 mE 8468757.51 mN Zone 18L,这是正确的。相比之下,sp变换后的对象是:

\n\n
SpatialPoints:\n           X1       X2\n[1,] 12051333 14804033\n[2,] 12569894 14792671\n[3,] 12301330 14684870\nCoordinate Reference System (CRS) arguments: +proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0 \n
Run Code Online (Sandbox Code Playgroud)\n\n

手册spTransform特别提到应正确提供元数据。我的数据使用 WGS84 椭球体并且位于 18L 区域。更准确地说是epsg:32718。我哪里错了?

\n

小智 5

我建议“投影”(即乘以-1)-180.0000、-90.0000、180.0000、90.0000范围内的点,因为它们位于南半球和西半球。

library(sp)

pasaporte <- structure(list(Latitud = c(13.84778, 13.01667, 13.15722), 
                            Longitud = c(73.75333, 75.08333, 74.22278)),
                       .Names = c("Latitud", "Longitud"), class = "data.frame", 
                       row.names = c("4", "36", "46"))

pasaporte <- pasaporte * -1

pasaporte
#      Latitud  Longitud
# 4  -13.84778 -73.75333
# 36 -13.01667 -75.08333
# 46 -13.15722 -74.22278

# Conversion into SpatialPoints
coordinates(pasaporte) <- ~Longitud+Latitud
# Setting default projection
proj4string(pasaporte) <- CRS('+init=epsg:4326')

pasaporte
# SpatialPoints:
#     Longitud   Latitud
# 4  -73.75333 -13.84778
# 36 -75.08333 -13.01667
# 46 -74.22278 -13.15722
# Coordinate Reference System (CRS) arguments: +init=epsg:4326
# +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 

# Projection
# Be sure to have rgdal first installed.
xy_utm <- spTransform(pasaporte, CRS('+init=epsg:32718'))
xy_utm
# SpatialPoints:
#    Longitud Latitud
# 4  634726.5 8468758
# 36 490964.2 8561019
# 46 584231.8 8545348
# Coordinate Reference System (CRS) arguments: +init=epsg:32718 +proj=utm
# +zone=18 +south +datum=WGS84 +units=m +no_defs +ellps=WGS84
# +towgs84=0,0,0 
Run Code Online (Sandbox Code Playgroud)