# Converting decimal degrees (longitude & latitude) to UTM WGS84 in R? (Southern hemisphere)

I'm trying to convert some longitude and latitude coordinates to UTM WGS84 projection. I'm using rgdal, although I can accommodate to other package (in R). I read the data and converted it to a `SpatialPoints` object:

``````coordinates(res) <- ~Lat_dec + Lon_dec
proj4string(res) <- CRS('+proj=longlat +datum=WGS84')
``````

my points:

``````res
SpatialPoints:
Lon_dec   Lat_dec
35 -78.60972 -9.073333
36 -78.61806 -9.078611
37 -78.60889 -9.093611
38 -78.59167 -9.088889
39 -78.57917 -9.100833
40 -78.56833 -9.112778
41 -78.59278 -9.113333
42 -78.61139 -9.119167
43 -78.57778 -9.122778
44 -78.56889 -9.135833
45 -78.59278 -9.137222
46 -78.60222 -9.160278
47 -78.57472 -9.152778
48 -78.59583 -9.152778
Coordinate Reference System (CRS) arguments: +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
``````

The following error is no longer produced since swapping the coordinates to negative values (south america) Now, when I try to transform the points using `spTransform(res, CRS('+proj=utm +zone=17 ellps=WGS84'))` I get an error and a warning:

``````non finite transformation detected:
Lat_dec   Lon_dec
9.073333 78.609722       Inf       Inf
Error in spTransform(res, CRS("+proj=utm +zone=17 ellps=WGS84")) :
failure in points 1
In spTransform(res, CRS("+proj=utm +zone=17 ellps=WGS84")) :
14 projected point(s) not finite
``````

When I try to convert using `project(coordinates(res), '+proj=utm +zone=17 ellps=WGS84')` I get the projection:

``````   [,1] [,2]
[1,]  Inf  Inf
[2,]  Inf  Inf
[3,]  Inf  Inf
[4,]  Inf  Inf
[5,]  Inf  Inf
[6,]  Inf  Inf
[7,]  Inf  Inf
[8,]  Inf  Inf
[9,]  Inf  Inf
[10,]  Inf  Inf
[11,]  Inf  Inf
[12,]  Inf  Inf
[13,]  Inf  Inf
[14,]  Inf  Inf
Warning message:
In project(coordinates(res), "+proj=utm +zone=17 ellps=WGS84") :
14 projected point(s) not finite
``````

Changed according to the suggestions below and now this is produced

``````> project(coordinates(res), '+proj=utm +zone=17 ellps=WGS84')
[,1]     [,2]
[1,] 762744.8 -1003824
[2,] 761824.4 -1004402
[3,] 762821.6 -1006069
[4,] 764719.2 -1005559
[5,] 766085.1 -1006890
[6,] 767267.6 -1008219
[7,] 764579.0 -1008263
[8,] 762528.0 -1008895
[9,] 766221.6 -1009319
[10,] 767189.3 -1010770
[11,] 764561.3 -1010906
[12,] 763505.8 -1013450
[13,] 766535.2 -1012641
[14,] 764213.9 -1012625
``````

Which are undeniably wrong. The latitude should be positive and near 899####.

• spTransform() will never let you have out of bounds coordinates, but project() will - but project won't perform datum transformations. That's the only real difference. sp/rgdal always uses longitude,latitude order. Why use UTM? Do you have to? It's probably the worst choice of all unless you are forced. Commented Sep 29, 2016 at 0:58
• I have my hands tied regarding the projection choice... Commented Sep 29, 2016 at 14:57

Add a +south parameter to the utm PROJ.4 string. That will automatically add a false northing value of 10000000 meters.

"+proj=utm +zone=17 +south=T ellps=WGS84"

Note: I can't find the "=T" in the PROJ.4 documentation on the "+south" parameter, but two people agree that it works when using R.

• almost - needs to be `+south=T` Commented Sep 28, 2016 at 22:22
• That's not standard proj4 usage. Is it specific to R's implementation? Do you have a reference? Commented Sep 29, 2016 at 0:50
• Must be? Can't find a reference - all I know is that '+south' didn't work alone, and I added '=T' on a hunch. Then it worked. Commented Sep 29, 2016 at 0:59
• worked with south=T, change the answer so I can mark as correct Commented Sep 29, 2016 at 15:31
• I wish I knew what "=T" meant! Commented Sep 29, 2016 at 18:52

Latitude is Y. Try `coordinates(res) <- ~ Long_dec + Lat_dec`

If you're in zone 17 (panama?), those longitudes should be negative.

• this is true, but the coordinates are wrong (checked on google earth) Commented Sep 28, 2016 at 20:31