Convert Arcminute / Second to decimal (irregular format)

تعرفه تبلیغات در سایت
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس
عنوان عکس

آرشیو مطالب

جستجوگر

یافته ها در جستجو

    امکانات وب

    برچسب ها

    Vote count: 0

    I'm dealing with some irregular and poorly thought through data with GPS coordinates and I need to make them more useable and pipeable.

    I've been basing my work on the angle2dec function that I found on here:

    angle2dec <- function(angle) {
      angle <- as.character(angle)
      x <- do.call(rbind, strsplit(angle, split=' '))
    
      #decimal points where they should and should not be here
      #causes my issue as i can't use a consistent string split
      #character.  splitting the first 3 '.' occurrences might work
    
      x <- apply(x, 1L, function(y) {
        y <- as.numeric(y)
        y[1] + y[2]/60 + y[3]/3600
      })
      return(x)
    }
    

    However my data is not nicely formatted. A coordinate looks like this:

    '53.17.35.852'
    

    The ang2dec function works for coordinates that follow this format:

    ang2dec('53 17 35.852') = 53.29329
    

    (This is the correct result)

    Clearly the problem is the poor choice of formatting of the coordinate. Can anyone suggest a way that I can convert the first format of coordinate into the second or propose changes to the ang2dec function that would include the functionality that I am looking for?

    asked 11 secs ago

    نویسنده : استخدام کار بازدید : 53 تاريخ : چهارشنبه 27 ارديبهشت 1396 ساعت: 21:57
    برچسب‌ها :

    خبرنامه

    عضویت

    نام کاربري :
    رمز عبور :