Converting ISO 6709 Formatted GPS Coordinates to Decimal Degrees in R

We have a piece of equipment that outputs its GPS coordinates as numeric values to file in an ISO 6709 lat/lon format of Lat = ±DDMM.MMMM & Lon = ±DDDMM.MMMM

Are there any packages with functions (or custom functions) in R that will convert this to a Decimal degrees format? (ie: ±DD.DDDDDD & ±DDD.DDDDDD)

An example would be that lat & lon (2433.056, -8148.443) would be converted to (24.55094, -81.80739).

Answers


You could read in the values from the file using something like read.csv or read.delim.

Then to convert from DDMM.MMMM and DDDMM.MMMM you could use something like this (of course modify as needed for the form of your input/outputs):

convertISO6709 <- function( lat, lon ) {
    # will just do lat and lon together, as the process is the same for both
    # It's simpler to do the arithmetic on positive numbers, we'll add the signs
    #  back in at the end.
    latlon <- c(lat,lon)
    sgns   <- sign(latlon)
    latlon <- abs(latlon)

    # grab the MM.MMMM bit, which is always <100. '%%' is modular arithmetic.
    mm <- latlon %% 100

    # grab the DD bit. Divide by 100 because of the MM.MMMM bit.
    dd <- (latlon - mm)/100

    # convert to decimal degrees, don't forget to add the signs back!
    out_latlon <- (dd+mm/60) * sgns
    return(out_latlon)
}

Need Your Help

Renaming a macro

excel vba excel-vba

I am using the same macro twice on a sheet. The sheet will not let me use both unless I rename one. Whenever I have tried it stops functioning.

HTML5 offline google map access

jquery html5 google-maps jquery-mobile

We are developing a HTML5 application which has a Google map to change the location of search.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.