如何将 Longitude/Latitude 度转换为 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
通过邮件列表中提供的answer,我已经将数据转换为十进制形式...
> 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
继续变换投影
xy_utm <- spTransform(xy, CRS('+proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84:0,0,0'))
我已经使用 this website 转换了示例中的第一个坐标(确保提供负数,因为坐标指的是南和西),并提供以下坐标: 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。我哪里出错了?
我建议 "project"(即乘以 -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
我的数据是经纬度投影,以度分秒的形式表示。这已经以文本形式存储(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
通过邮件列表中提供的answer,我已经将数据转换为十进制形式...
> 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
xy_utm <- spTransform(xy, CRS('+proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84:0,0,0'))
我已经使用 this website 转换了示例中的第一个坐标(确保提供负数,因为坐标指的是南和西),并提供以下坐标: 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。我哪里出错了?
我建议 "project"(即乘以 -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