Convert dispersion in meters to brilliant

I made a fileInput which loads a .CSV file [dataset contains latitude and longitude] directly after the user has selected it.

data <- data.frame(
         Lat=c(21.076,21.99,20.95,20.00,26.57,25.70),
         long=c(60.000,67.980,61.00061.009,69.001,62.000,61.056,62.789,63.546)
)

      

Problem: I want variance values ​​in meters.

ui.r

 library(shiny)
 library(ggplot2)
 shinyUI(fluidPage(
 fileInput('file', 'Choose CSV file',
        accept=c('csv', 'comma-separated-values','.csv')),

      

server.r

library(shiny)
library(ggplot2)

shinyServer(function(input, output,session) {

 a<-reactive({
if (is.null(input$file))
   return(NULL)                
 a<-read.csv(input$file$datapath)
 a<- transform(a, var1 =var(Lat), var2= var(Long))
 # Now I want to convert this variance in meters and den display it
 a
  ))

      

+3


source to share


1 answer


You can try using the PBSmapping package.

This can convert lat / long to UTM coordinates. You have to be careful about which hemisphere you use when setting up your data. For example. if you are in the western hemisphere, you may have to put a minus ("-") from longitude. It is best if you know which UTM zone you are in (you can google it).



In case you are wondering why I used capital "X" and "Y" when I created the DataFL DataLL below, it is because this is a feature requirement.

require(PBSmapping)

data <- data.frame(
  Lat=c(21.076,21.99,20.95,20.00,26.57,25.70,20.00,26.57,25.70),
  Long=c(60.000,67.980,61.000,61.009,69.001,62.000,61.056,62.789,63.546)
)

dataLL=as.data.frame(list(X=data$Long,Y=data$Lat))
# or if in western hemis:
#dataLL=as.data.frame(list(X=-data$Long,Y=data$Lat))

attr(dataLL,"projection")="LL"
#km=F puts the projection in meters, it automatically finds what UTM zone to use
dataUTM=convUL(dataLL,km=F)

plot(dataUTM$X,dataUTM$Y)

      

0


source







All Articles