sl.xyz2lonlat: Convert X-Y-Z to Lon-Lat

View source: R/sl.xyz2lonlat.R

sl.xyz2lonlatR Documentation

Convert X-Y-Z to Lon-Lat

Description

Covert one or more points from x-y-z (unit sphere) to longitude-latitude coordinates.

Usage

sl.xyz2lonlat(xyzvec=NULL, x=NULL, y=NULL, y=NULL)

Arguments

xyzvec

a vector of length 3 with the x, y, and z coordinates of a single point, or NULL (default).

x

a vector or array with the x coordinates of one or more points, or NULL (default). Used only if xyzvec=NULL.

y

a vector or array with the y coordinates of one or more points, or NULL (default). Used only if xyzvec=NULL.

z

a vector or array with the z coordinates of one or more points, or NULL (default). Used only if xyzvec=NULL.

Details

If the point(s) is/are not located on the unit sphere, they are accordingly shortened/elongated.

Value

If xyzvec=NULL, a list with elements lon and lat, each of which are vectors or arrays of the same size as x,y,z with the latitudes and longitudes of the points. Otherwise, a single vector of length 2 with the longitude and latitude of the single point.

Author(s)

Helge Goessling

See Also

sl.lonlat2xyz

Examples

sl.xyz2lonlat(xyzvec=c(0,1/sqrt(2),1/sqrt(2)))
## Should return:
## [1] 90 45

sl.xyz2lonlat(x=1:5,y=seq(-2,2),z=c(2.543,1.3676,0.432,1.4,-5.22))
## Should return:
## $lon
## [1] -63.43495 -26.56505   0.00000  14.03624  21.80141
## 
## $lat
## [1]  48.674731  31.450344   8.194263  18.754912 -44.107748

helgegoessling/spheRlab documentation built on April 8, 2024, 8:34 a.m.