Apologies if I'm not using the correct terminology. But I am looking for a way to convert geocoded Latitude and Longitude to a Degree format which shows GPS (NS/EW) coordinates in R.
lat lon
43.651070 -79.347015
43.6532° N, 79.3832° W
lat lon
-37.840935 144.946457
37.8136° S, 144.9631° E
sample_data = data.frame(
lat = c(43.651070, -37.840935),
lon = c(-79.347015, 144.946457)
)
with(sample_data, paste0(
abs(lat), "° ", ifelse(lat > 0, "N", "S"), ", ",
abs(lon), "° ", ifelse(lon > 0, "E", "W")
))
# [1] "43.65107° N, 79.347015° W" "37.840935° S, 144.946457° E"