Your example is not exactly reproducible, so allow me to continue with one of mine. It is built on three Prague landmarks, locations for which are defined in metric Eastings & Northings.
My data is in local Czech Coordinate Referrence System, standardized as EPSG:5514; you will have to replace this figure in your actual code (it seems your data is in British National Grid = EPSG:27700).
My code is built on the highly recommended {sf} package, and does several steps:
- read in a data frame of fake data
- transform the data frame into a spatial object
- reproject the spatial object from planar to angular CRS (the good old WGS84)
- calculate colums for longitude and latitude & remove the spatial characteristic
It can be then saved as a CSV or what not and uploaded to Power BI.
library(sf)
library(dplyr)
fake_data <- tribble(~name, ~x, ~y,
"Kramářova vila", -743492, -1042264,
"Prazský hrad", -744360, -1042569,
"Strakova akademie", -743416, -1042417)
sf_data <- fake_data %>%
st_as_sf(coords = c("x", "y"), crs = 5514) %>%
st_transform(4326) %>%
mutate(lon = st_coordinates(.)[,1],
lat = st_coordinates(.)[,2]) %>%
st_set_geometry(NULL)
Note that the more purist approach would be to stay in R, and prepare a visualization using the Leaflet package. It is not hard...
(please excuse my little joke - I needed a verification since I always seem to mix up lon & lat
)
library(leaflet)
sf_data %>%
st_as_sf(coords = c("lon", "lat"), crs = 4326) %>%
leaflet() %>%
addProviderTiles("Stamen.Toner") %>%
addMarkers()