I have seen code for this in python, but can't figure out how to do it in R. I have some code but it isn't working for me.
My data has a column with latitude and a column with longitude but they are in the national grid system. I don't know how to post a data set to help
I am trying to use rgdal. I take the lat and long and make a lat, long variable. The code I have found that should help is this
library(rgdal)
whiskies$whiskies.coord = paste0(whiskies$Latitude, ", ", whiskies$Longitude)
proj4string(whiskies$whiskies.coord) = CRS("+init=epsg:27700") # Specify that our coords are in osgb grid coord
whiskies.coord <- spTransform(whiskies.coord, CRS("+init=epsg:4326")) # spTransform to convert osgb grid to lat/lon
I don't know if I set up the whiskies.coord properly is the base problem. When I run the third command I get this error
Error in (function (classes, fdef, mtable) : unable to find an inherited method for function ‘proj4string<-’ for signature ‘"character", "CRS"’
RowID Distillery Latitude Longitude 1 Aberfeldy 286580 749680 2 Aberlour 326340 842570 3 AnCnoc 352960 839320