将Lat / Long投影到UTM:错误

时间:2015-01-08 15:50:07

标签: r rgdal utm sp

提前致谢。

我需要转换为UTM的纬度/长度为86,000点。本文包括25个样品。我已经找到了许多帮助完整的SO帖子,但继续收到工作示例的错误,如下所述。

示例数据在这里:

    locs <- structure(list(LocNum = 1:25, IndID = structure(c(1L, 1L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 
2L, 3L, 3L, 3L, 3L, 3L), .Label = c("011_A", "015_A", "034_A"
), class = "factor"), FixDateTimeLocal = structure(1:25, .Label = c("2012-02-16 17:00:00", 
"2012-02-16 23:00:00", "2012-02-17 05:00:00", "2012-02-17 11:00:00", 
"2012-02-17 17:00:00", "2012-02-17 23:00:00", "2012-02-18 05:00:00", 
"2012-02-18 11:00:00", "2012-02-18 17:00:00", "2012-02-18 23:00:00", 
"2012-02-27 14:00:00", "2012-02-27 15:30:00", "2012-02-27 16:00:00", 
"2012-02-27 17:00:00", "2012-02-27 23:00:00", "2012-02-28 05:00:00", 
"2012-02-28 11:00:00", "2012-02-28 17:00:00", "2012-02-28 23:00:00", 
"2012-02-29 05:00:00", "2013-01-19 17:00:00", "2013-01-19 23:00:00", 
"2013-01-20 05:00:00", "2013-01-20 11:00:00", "2013-01-20 17:00:00"
), class = "factor"), Lat = c(45.120814, 45.120802, 45.120761, 
45.116529, 45.105876, 45.104819, 45.104803, 45.104491, 45.103639, 
45.10427, 45.092519, 45.094687, 45.098596, 45.099671, 45.099709, 
45.099422, 45.097036, 45.097139, 45.098102, 45.098099, 44.962221, 
44.962904, 44.967558, 44.968786, 44.973531), Long = c(-110.817359, 
-110.817405, -110.818067, -110.806221, -110.797895, -110.796213, 
-110.795224, -110.795689, -110.799264, -110.799369, -110.783507, 
-110.78943, -110.791256, -110.794017, -110.794075, -110.794205, 
-110.792251, -110.792, -110.791296, -110.791331, -109.85984, 
-109.859536, -109.860217, -109.86568, -109.881313)), .Names = c("LocNum", 
"IndID", "FixDateTimeLocal", "Lat", "Long"), row.names = c(NA, 
-25L), class = "data.frame")

有3个人的ID,时间戳(尚未作为POSIXct),lat和long。

  LocNum IndID    FixDateTimeLocal      Lat      Long
1      1 011_A 2012-02-16 17:00:00 45.12081 -110.8174
2      2 011_A 2012-02-16 23:00:00 45.12080 -110.8174
3      3 011_A 2012-02-17 05:00:00 45.12076 -110.8181
4      4 011_A 2012-02-17 11:00:00 45.11653 -110.8062
5      5 011_A 2012-02-17 17:00:00 45.10588 -110.7979
6      6 011_A 2012-02-17 23:00:00 45.10482 -110.7962

我按照here提出的建议并使用了以下代码:

library(sp)
library(rgdal)
pts <- SpatialPoints(cbind(locs$Lat,locs$Long), 
                     proj4string = CRS("+proj=longlat +datum=WGS84"))

得到了

Error in validityMethod(as(object, superClass)) : 
  Geographical CRS given to non-conformant data: -110.818067

根据建议的here删除否定长度

pts <- SpatialPoints(abs(cbind(locs$Lat,locs$Long)), 
                     proj4string = CRS("+proj=longlat +datum=WGS84"))

得到了

Error in validityMethod(as(object, superClass)) : 
  Geographical CRS given to non-conformant data: 110.818067

最后,正如here建议使用矩阵我跑

pts <- project(as.matrix(locs[,c("Lat","Long")]), "+proj=utm +zone=12 ellps=WGS84")

得到了

Warning message:
In project(as.matrix(locs[, c("Lat", "Long")]), "+proj=utm +zone=12 ellps=WGS84") :
  25 projected point(s) not finite

有关如何将这些纬度/经度点转换为UTM的任何建议都将受到赞赏。纬度/经度在WGS84,我的UTM区域为12。

0 个答案:

没有答案