Converting coordinates in R is straightforward with spTransform etc, but is there a way to bypass the Spatial object and convert directly in the dataframe? To just run the transformation equation on 2 columns? E.g. from latlon to British National Grid as new columns:
# current way using a spatial object
require(raster)
require(rgdal)
# define BNG and latlon
BNG <- CRS("+init=epsg:27700")
LL <- CRS("+init=epsg:4326")
# dummy data
toconv <- data.frame(id=c("a","b","c"), lat=c(54.530776,54.551913,54.455268), lon=c(-2.6006958,-2.4084351,-2.4688599))
# promote to spatial points data frame and define CRS of points
coordinates(toconv) = ~lon + lat
crs(toconv) <- LL
# current LL coordinates as columns in the SPDF
toconv$Xlon <- coordinates(toconv)[,1]
toconv$Ylat <- coordinates(toconv)[,2]
# transform to BNG
conv <- spTransform(toconv, crs(BNG))
# rename the coords from original name to new wanted name
colnames(conv@coords) <- c("Xbng","Ybng")
# extract as data frame, new coords with new name are new columns.
final <- as.data.frame(conv)
However i want to go from the original dummy data ('toconv') straight to the final output ('final') without faffing around, is is possible in one function? (e.g. a function containing the Helmert Transformation or OSTN02 Transformation)