deg2km: Degree and Kilometer Conversion

View source: R/deg2km.R

deg2kmR Documentation

Degree and Kilometer Conversion

Description

Convert geographical coordinates to kilometers and vice versa.

Usage

deg2km(x, y, long.ref, lat.ref, method = "utm")

km2deg(x, y, long.ref, lat.ref, method = "utm")

Arguments

x, y

A numeric vector of longitude and latitude coordinates. Coordinates are assumed to be in decimal degree format.

long.ref, lat.ref

Reference coordinate from which the coordinate distances will be calculated. Assumed to be in decimal degree format.

method

Character string specifying the method to be used for calculating the distances between coordinate points. The options are ‘utm’ which first converts the coordinates into UTM NAD83 coordinates, and ‘ellipsoid’ which models the Earth as an ellipsoid with major and minor radii of 6378.16 and 6356.775 kilomters, respectively. The default is ‘utm’.

Value

A data frame containing the converted coordinates.

Functions

  • deg2km(): Convert coordinates from decimal lat-lon to kilometers (UTM).

  • km2deg(): Convert coordinates from kilometers to decimal lat-lon.

See Also

loran2deg, deg2dms, deg2dmm, deg2str

Examples

# Convert a decimal degree coordinate to kilometers format:
deg2km(-63.123, 47.56)

# Convert a vector of decimal degree coordinates to kilometer format:
deg2km(seq(-65, -63, len = 21), seq(46, 48, len = 21))

#Convert a coordinate in kilometer format to decimal degree format:
km2deg(-227.3639, 111.1331)

# Return the value of the reference coordinate:
km2deg(0, 0)

# Convert a vector of kilometer-format coordinates to decimal degree format:
km2deg(seq(0, -200, len = 21), seq(0, 100, len = 21))


TobieSurette/gulf.spatial documentation built on Sept. 26, 2024, 7:41 p.m.