[R-sig-Geo] Lat Long --> UTM again

Hodgess, Erin HodgessE at uhd.edu
Mon Jun 17 22:53:21 CEST 2013

Hi Joana:

You may want to check out this website:

I think that you're getting the false northing and easting.


-----Original Message-----
From: r-sig-geo-bounces at r-project.org [mailto:r-sig-geo-bounces at r-project.org] On Behalf Of Joana Ruela Boavida
Sent: Monday, June 17, 2013 3:05 PM
To: r-sig-geo at r-project.org
Subject: [R-sig-Geo] Lat Long --> UTM again


perhaps someone can help. i'm trying to convert coordinates from decimal degrees (WGS84) to UTM zone 29S (Portugal), but i have two problems:

1) i always get a wrong northing. I've read all messages regarding this subject and online documentation, which greatly helped, but i still couldn't get the correct northing. This is the code i used:

#csv file with raw data
frames<-read.table("framescoords.csv", sep=";", header=T) dd <- cbind(frames$long, frames$lat) LatLong <- data.frame(X = dd[,1], Y = dd[,2]) #X is longitude

#convert to sp object:
coordinates(LatLong) <- ~ Y + X #longitude first

#adding a coordinate reference system:
proj4string(LatLong) <- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84") LatLong

#project using sp transform:
UTM <- spTransform(LatLong, CRS("+proj=utm +zone=29 +north +ellps=WGS84

e.g. for the coordinates pair (dd): 36,9892160333 and -8,4846898591 i get:

          Y        X
 [1,] 5e+05 -9997965
Coordinate Reference System (CRS) arguments: +proj=utm +zone=29
+ellps=WGS84 +datum=WGS84 +towgs84=0,0,0

i believe i should be getting: 545 856.274 and  4 093 809.460 Meters

i also tried:
proj4string(LatLong) <- CRS("+init=epsg:32629") UTM <- spTransform(LatLong, CRS("+init=epsg:32629")) UTM

and got:

             Y         X
 [1,] 36.98933 -8.484690
 [2,] 36.98926 -8.484682
 [3,] 36.98921 -8.484672
Coordinate Reference System (CRS) arguments: +init=epsg:32629 +proj=utm
+zone=29 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0

so, no transformation.

2) Another problem is that regardless the values being correct or not, i get the same value for all points (in fact they are very close to each other but i need to get a distance matrix in meters, so i really need this to be accurate):

          Y        X
 [1,] 5e+05 -9997965
 [2,] 5e+05 -9997965
 [3,] 5e+05 -9997965
 [4,] 5e+05 -9997965
 [5,] 5e+05 -9997965

Finally, it is not feasible to do it using an online conversion tool since i need to repeat this for many coordinates and for many different sites, and the few that i've tried give always the same coordinates, ie, don't have enough resolution for close points(?).

Any comments may be helpful. Thank you very much, joanna

	[[alternative HTML version deleted]]

R-sig-Geo mailing list
R-sig-Geo at r-project.org

More information about the R-sig-Geo mailing list