I am trying to convert geographic coordinates (degrees) into UTM coordinates (meters) and keep getting an error message that a "Non finite transformation detected." Do you know how I can fix this? Here is the code I used:
> 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
I would check the data you are trying to convert. I was not able to access the data you have in your example so I just used the first 3 coordinate points you provided to try to replicate the error and did not get an error. I also checked to see if the error could be caused by having the UTM zone specified not include all points provided by changing the zone number and north/south parameter and still everything worked. I would perhaps create a loop that iterates through the data you want to convert in chunks to see where the problem lies...
Since you asked, here is a code to iterate through parts of the data. If you get an error you will at least know where in your data the problem came from: