Convert Lat-Lon to UTM and reverse

library(PBSmapping)
utm <- structure(list(x = c(160915.9, 161253.9, 161253.9), 
y = c(2573771, 2573763, 2573763)), .Names = c("x", 
"y"), row.names = c(NA, -3L), class = "data.frame")

datainUTM<-data.frame(cbind(utm$x/1000, 
                            utm$y/1000, 
                            rep(0, dim(utm)[1]), 
                            1:dim(utm)[1]))
names(datainUTM)<-c("X", "Y", "PID", "POS")
attr(datainUTM, "projection") <-"UTM"
attr(datainUTM, "zone") <-18
datosLL<-convUL(datainUTM)

> datosLL
         X       Y PID POS
1 -78.3133 23.2383   0   1
2 -78.3100 23.2383   0   2
3 -78.3100 23.2383   0   3

Alternative

library(sp)
library(rgdal)
orig <- data.frame(lat = c(23.2383,23.2383,23.2383), 
                   long = c(-78.3133,-78.3100,-78.3100), 
                   elv = c(4.01, 4.00, 4.00))
coordinates(orig) <- ~long+lat
proj4string(orig) <- CRS("+proj=longlat +ellps=WGS84")
orig <- spTransform(orig, 
         CRS("+proj=utm +zone=18 +north +units=m +ellps=WGS84"))
         
> orig
          coordinates  elv
1 (160915.9, 2573771) 4.01
2 (161253.9, 2573763) 4.00

3 (161253.9, 2573763) 4.00



Commentaires

Posts les plus consultés de ce blog

Standard error from Hessian Matrix... what can be done when problem occurs

stepAIC from package MASS with AICc

Install treemix in ubuntu 20.04