&引用;“检测到非有限变换”;rgdal R包中的SPT变换

&引用;“检测到非有限变换”;rgdal R包中的SPT变换,r,spatial,coordinate-systems,rgdal,R,Spatial,Coordinate Systems,Rgdal,我正在尝试将地理坐标(度)转换为UTM坐标(米),并不断收到“检测到非有限转换”的错误消息。您知道我如何修复此问题吗?以下是我使用的代码: > GPS.Points <- Gomer.Data[, c('Longitude', 'Latitude')] > head(GPS.Points) Longitude Latitude 1 23.85474 -19.52211 2 23.85531 -19.52243 3 23.85534 -19.52257 4 23.

我正在尝试将地理坐标(度)转换为UTM坐标(米),并不断收到“检测到非有限转换”的错误消息。您知道我如何修复此问题吗?以下是我使用的代码:

> GPS.Points <- Gomer.Data[, c('Longitude', 'Latitude')]
> head(GPS.Points)

  Longitude  Latitude
1  23.85474 -19.52211
2  23.85531 -19.52243
3  23.85534 -19.52257
4  23.85580 -19.52346
5  23.85551 -19.52380
6  23.85513 -19.52360

> GPS.Points.Spatial.Data <- SpatialPoints(GPS.Points, 
                                         proj4string=CRS("+proj=longlat +ellps=WGS84"))
> GPS.Points.Spatial.Data[1]

SpatialPoints:
     Longitude  Latitude
[1,]  23.85474 -19.52211
Coordinate Reference System (CRS) arguments: +proj=longlat +ellps=WGS84 

> class(GPS.Points.Spatial.Data)

[1] "SpatialPoints"
attr(,"package")
[1] "sp"

> GPS.Points.UTM.Spatial.Data <- spTransform(GPS.Points.Spatial.Data,
                                           CRS("+proj=utm +south +zone=34 +ellps=WGS84"))

non finite transformation detected:
     Longitude Latitude  
Error in spTransform(GPS.Points.Spatial.Data, CRS("+proj=utm +south +zone=34 +ellps=WGS84")) : 
  failure in points 
In addition: Warning message:
In spTransform(GPS.Points.Spatial.Data, CRS("+proj=utm +south +zone=34 +ellps=WGS84")) :
  3 projected point(s) not finite
>GPS.Points头部(GPS.Points)
经纬度
1  23.85474 -19.52211
2  23.85531 -19.52243
3  23.85534 -19.52257
4  23.85580 -19.52346
5  23.85551 -19.52380
6  23.85513 -19.52360
>GPS.Points.Spatial.Data GPS.Points.Spatial.Data[1]
空间点:
经纬度
[1,]  23.85474 -19.52211
坐标参考系(CRS)参数:+proj=longlat+ellps=WGS84
>类(GPS.点.空间.数据)
[1] “空间点”
属性(,“包”)
[1] “sp”

>GPS.Points.UTM.spatical.Data我会检查您试图转换的数据。我无法访问示例中的数据,所以我只使用了您提供的前3个坐标点来尝试复制错误,但没有得到错误。我还检查了错误是否是由指定的UTM区域不包括通过更改区域编号和北/南参数提供的所有点引起的,并且所有操作仍然有效。 我可能会创建一个循环,循环遍历要转换成块的数据,以查看问题所在

library(rgdal)

GPS.Points=data.frame(Longitude=c(23.85474, 23.85531, 23.85534))
GPS.Points=cbind(GPS.Points,Latitude=c(-19.52211, -19.52243, -19.52257))

GPS.Points.Spatial.Data <- SpatialPoints(GPS.Points, 
proj4string=CRS("+proj=longlat     +ellps=WGS84"))
GPS.Points.Spatial.Data[1]

class(GPS.Points.Spatial.Data)

GPS.Points.UTM.Spatial.Data <- spTransform(GPS.Points.Spatial.Data,
                          CRS("+proj=utm +south +zone=34 +ellps=WGS84"))
库(rgdal)
GPS.Points=data.frame(经度=c(23.85474,23.85531,23.85534))
GPS.Points=cbind(GPS.Points,纬度=c(-19.52211,-19.52243,-19.52257))

GPS.Points.Spatial.Data嗨,非常感谢您的回复!我对R相当陌生-你们能给我一些代码来告诉我如何运行大块的数据吗?当然,我不是专家,但我在上面包含了一个非常简单的代码。我下面的答案有帮助吗?如果是,请将其作为已接受的答案进行检查。。。
library(rgdal)
GPS.Points=data.frame(Longitude=c(23.85474, 23.85531, 23.85534, 23.85474, 
23.85531, 23.85534, 23.85474, 23.85531, 23.85534))
GPS.Points=cbind(GPS.Points,Latitude=c(-19.52211, -19.52243, -19.52257, -19.52211, 
-19.52243, -19.52257, -19.52211, -19.52243, -19.52257))

n_chunks=3 #number of pieces you will break you data into
n.points=dim(GPS.Points)[1]
breaks=seq(1,n.points, by=round(n.points/n_chunks))
breaks=c(breaks, n.points) #make sure to include last points as well

i=1
for (i in 1:(length(breaks)-1)){
  cat('\n','converting points', breaks[i], "to", breaks[i+1])  
  temp.GPS.Points=GPS.Points[breaks[i]:breaks[i+1],]
  temp.GPS.Points.Spatial.Data <- SpatialPoints(temp.GPS.Points, 
proj4string=CRS("+proj=longlat +ellps=WGS84"))
  temp.GPS.Points.UTM.Spatial.Data <- spTransform(temp.GPS.Points.Spatial.Data,
                                             CRS("+proj=utm +south +zone=34 
+ellps=WGS84"))
}