Learn R Programming

MODISTools (version 0.95.1)

ConvertToDD: Degrees Minutes Seconds/Decimal Minutes - Decimal Degrees Converter

Description

Takes a set of coordinates in either degrees minutes seconds or degrees decimal minutes, and converts them to decimal degrees format (##.#####; -##.#####). The function is flexible to take the input coordinates in several different formats.

Usage

ConvertToDD(XY, FileSep=NULL, LatColName, LongColName)

Arguments

XY
Input dataset; either the name of an object already in the workspace, or a file to be read in by specifying its file path as a character string.
FileSep
If XY is a character string that corresponds to a file path, choose the delimiter character for that file (e.g. "," for comma separated).
LatColName
Character string; the name of the column in XY containing latitude data.
LongColName
Character string; the name of the column in XY containing longitude data.

Value

Output is a data frame of same dimensions as input, with each value converted to decimal degrees, named "DD.lat" and "DD.long".

Details

There is flexibility in the layout of each degrees input format. For example, N-S/E-W can be described by positive-negative coordinates or by using respective letters at the end of each coordinate. For coordinates in degrees minutes seconds to be converted requires three numbers - degrees, minutes, and seconds - each separated by a single non-numeric character (e.g. 51d24'51.106"N 0d38'56.018"W). For coordinates in degrees minutes to be converted requires just two numbers - degrees and minutes (e.g. 51d24.106'N 0d38.018'W). Coordinates should not contain spaces in between the numbers. The degrees format does not have to be consistent throughout the data set.

See Also

MODISSubsets

Examples

Run this code
data(ConvertExample)
ConvertToDD(XY=ConvertExample, LatColName="lat", LongColName="long")

Run the code above in your browser using DataLab