Learn R Programming

GeoThinneR (version 1.0.0)

long_lat_to_cartesian: Convert Geographic Coordinates to Cartesian Coordinates

Description

This function converts geographic coordinates, given as longitude and latitude in degrees, to Cartesian coordinates (x, y, z) assuming a spherical Earth model.

Usage

long_lat_to_cartesian(long, lat, R = 6371)

Value

A numeric matrix with three columns (x, y, z) representing Cartesian coordinates.

Arguments

long

Numeric vector of longitudes in degrees.

lat

Numeric vector of latitudes in degrees.

R

Radius of the Earth in kilometers (default: 6371 km).

Examples

Run this code
long <- c(-122.4194, 0)
lat <- c(37.7749, 0)
long_lat_to_cartesian(long, lat)

Run the code above in your browser using DataLab