I want to transform lat/long coordinates into the UTM (zone 47) system using R. I have finally managed to get a result without error messages by using the last post on the bottom. But the result is not as expected. Here an example:
LongLatToUTM<-function(x,y,zone){
xy <- data.frame(ID = 1:length(x), X = x, Y = y)
coordinates(xy) <- c("X", "Y")
proj4string(xy) <- CRS("+proj=longlat +datum=WGS84") ## for example
res <- spTransform(xy, CRS(paste("+proj=utm +zone=",zone," ellps=WGS84",sep='')))
return(as.data.frame(res))
}
# Execute
x<-100.4605
y=21.568216
res.1<-LongLatToUTM(x,y,47)
I get the following result: x=646172.7 y=2876501 with R, but I'm expecting x=651218 y=2385744. What did I do wrong?