Forum Discussion

someonerandom's avatar
someonerandom
Regular Visitor
5 years ago

How to use this R function to convert easting northing to long lat

Hi,

 

I have around 900 gpd data points that i wish to convert to long/lat to use in the bing maps for visualisations.

 

I have googled to see how and this link below seems to provide the answer and how to i need

https://tonyladson.wordpress.com/2016/08/15/converting-from-utm-to-lat-long/ 


the code im supposed to use contains an R function however i cannot figure out how to use it, im not new to powerbi but i have no idea how to use a R function or for this code below to use my data,

 

library(dplyr)
library(ggmap)

# Source the UTM2deg function

source("https://gist.githubusercontent.com/TonyLadson/f37aab3e2ef517188a7f27166307c985/raw/0822970769bc90fcc28052a91b375399d665286e/UTM2deg.R")


# Some sample data

test_df <-
  structure(list(Location = c("Summerhill Road, Craigieburn", "Roseneath Street, Yarra Bend"
  ), Northing = c(5839684, 5815224), Easting = c(320312, 324192)), .Names = c("Location", "Northing", "Easting"
                                                          ), row.names = c(NA, -2L), class = c("tbl_df", "tbl", "data.frame"
                                                          ))


# Add columns of lat and lon using the UTM2deg function

test_df <- bind_cols(test_df, UTM2deg(test_df$Easting, test_df$Northing, zone = 55))
test_df

# Centre of the map
map_center <- test_df %>% 
  summarise(lon = mean(lon), lat = mean(lat))

# plot 
ggmap(get_map(map_center, zoom = 11, source = 'osm', maptype = 'terrain'), darken = c(0.3, 'black'), extent = 'device') +
  geom_point(data = test_df, aes(lon, lat), colour = 'red', size = 2) +
  geom_label(data = test_df, aes(lon, lat, label = Location), colour = 'red', fontface = 'bold', hjust = 0, vjust = -0.5)

 

My data is stored on sharepoint online the data list is called GPSHOLEDATA and this is how my data is displayed, how do i make the function above use my data so i can add a lat long column for each easting and northing? could someone break it down for me and explain it too me?

 

 

 

4 Replies