我的数据是以度、分钟和秒的形式以纬度和经度投影的。它以文本形式存储(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进行投影变换。
xy_utm <- spTransform(xy, CRS('+proj=utm +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84:0,0,0'))我在示例中转换了第一个坐标,使用本网站 (make提供负坐标,因为坐标引用了南部和西部),并提供了以下坐标: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。我哪里出问题了?
发布于 2015-05-25 03:11:11
我建议“投射”(即乘以-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 https://stackoverflow.com/questions/30429384
复制相似问题