# The following code transforms geographical coordinates (longitude and latitude) # expressed in degrees decimals (WGS84) into x/y ETRS89 transfo.fct <- function(Lon,Lat) { tab <- data.frame(Latitude = Lat, Longitude = Lon) library(rgdal) coords <- as.data.frame(cbind(Lon, Lat)) SP.temp <- SpatialPointsDataFrame(coords = coords ,data=as.data.frame(rep(1,length(Lon))) ,proj4string = CRS("+init=epsg:4326")) attributes(SP.temp) coordinates(SP.temp) SP.proj <- spTransform(SP.temp, CRS("+init=epsg:3034")) coordinates(SP.proj) tab$X <- coordinates(SP.proj)[, 1] tab$Y <- coordinates(SP.proj)[, 2] return(tab) } invtransfo.fct <- function(x,y) { library(rgdal) # Source data coords <- as.data.frame(cbind(x, y)) SP.temp <- SpatialPointsDataFrame(coords =coords , data=as.data.frame(rep(1,length(y))), proj4string = CRS("+init=epsg:3034")) SP.proj <- spTransform(SP.temp, CRS("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs")) ww <- coordinates(SP.proj) return(ww) }