繁体   English   中英

如何将经度/纬度转换为UTM? R.Rgdal,Sp

[英]How to transform Longitude/Latitude degree to UTM? R. rgdal, sp

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

> pasaporte
         Latitud        Longitud
4  13°50¨52" sur 73°45¨12" oeste
36    13°01¨ sur    75°05¨ oeste
46 13°09¨26" sur 74°13¨22" oeste

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

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

之后,我将data.frame转换为SpatialPoints对象。

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

然后通过spTransform进行投影spTransform

xy_utm <- spTransform(xy, CRS('+proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84:0,0,0'))

我已使用该网站转换了示例中的第一个坐标(请确保提供负数,因为坐标是指南和西),并提供以下坐标: 633726.46 mE 8468757.51 mN Zone 18L ,这是正确的。 相反,转换后的sp对象为:

SpatialPoints:
           X1       X2
[1,] 12051333 14804033
[2,] 12569894 14792671
[3,] 12301330 14684870
Coordinate Reference System (CRS) arguments: +proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0 

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

我建议对-180.0000,-90.0000、180.0000、90.0000边界中的点进行“投影”(即乘以-1),因为它们位于南半球和西半球。

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 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM