latitude longitude - Trouble converting UTM to lat long for southern hemisphere -


i have ~40 points in utm zone 19 taken peru convert lat/long project onto google earth. having problems pbsmapping , can't seem figure out solution. have searched through forums , tried several different methods, including project command in proj4 still can't work. here code have written

library(pbsmapping) #just 2 example utm coordinates data<-as.data.frame(matrix(c(214012,197036,8545520,8567292),nrow=2)) attr(data,"projection") <- "utm" attr(data, "zone") <- 19 colnames(data)<-c("x","y") convul(data,km=false) 

the corresponding lat/longs should somewhere lats between -12.9xxxxx , -13.0xxxxx , long between -71.8xxxx -71.4xxxx. values given convul seem way off.

once valid pairs of coordinates this:

library(rgdal) data <- data.frame(id = c(1:2), x = c(214012,197036) , y = c(8545520,8567292)) coordinates(data) = ~x+y 

asign projection

# use appropriate epsg code proj4string(data) = crs('+init=epsg:24891') # 24891 or 24893 

transform geographic coordinates enter code heredata_wgs84 <- sptransform(data, crs('+init=epsg:4326'))

get valid background data plot against

# country data package(dismo) peru <-getdata('gadm', country='per', level=0) plot(peru, axes = t) plot(data, add = t) 

write kml file

# export kml tmpd <- 'd:\\' writeogr(data_wgs84, paste(tmpd, "peru_data.kml", sep="/"), 'id', driver="kml") 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -