Hi, I'm new, graphing in R and I have the following problem.
I have some sample points in an XLSX file.
Latitud Longitud Altura
19°10'40.11"N 97°38'15.45"O 2362
19°10'37.85"N 97°38'28.32"O 2361
19°10'36.21"N 97°38'27.47"O 2359
and my code is as follows
library(plotGoogleMaps)
data.xlsx <- read.xlsx("AreaPrueba1.xlsx", sheetIndex = 1,stringsAsFactors=FALSE)
head(data.xlsx)
data.xlsx$Altura <-as.integer((as.character(data.xlsx$Altura)))
# creamos esta función para transformar las coordenadas geográficas a decimal
geo2dec<-function(c) {
z<-sapply( strsplit(c, "[°\'\"]"), as.character )
dec<- as.numeric(z[1, ]) + as.numeric(z[3, ])/60 + as.numeric(z[4, ])/3600
if (z[5, ]=="N"||z[5, ]=="E") dec else -dec
}
data.xlsx$Latitud<-geo2dec(data.xlsx$Latitud)
data.xlsx$Longitud<-geo2dec(data.xlsx$Longitud)
#aqui el problema
pts <- data.frame(x=data.xlsx$Longitud,y=data.xlsx$Latitud)
coordinates(pts) <- ~x+y
proj4string(pts) <- CRS('+init=epsg:32614')
m<-plotGoogleMaps(pts,filename='EjemploCampo.htm',mapTypeId='ROADMAP',layerName = 'Puntos de Medición')
My problem is that I do not understand how to translate the coordinates correctly so that I referenced the points well, change the + init = epsg: 32614 , for the area where the points are but the output map I get it wrong, it throws me into the sea.