convert.globe: Convert coordinates for plotting

View source: R/convert.globe.R

convertpointsR Documentation

Convert coordinates for plotting

Description

Convert a matrix of spherical coordinates into a format that can be plotted using functions available in either the globe or sphereplot packages

Usage

convert.globe(X, inverse=FALSE, sp.dim=2)
convert.sphereplot(X, inverse=FALSE, sp.dim=2)

Arguments

X

If inverse=TRUE, a 2 or 3 column matrix containing spherical coordinates of points to be plotted. If inverse=FALSE and using convert.globe, a list of length 2 with values lat and lon. If inverse=FALSE and using convert.sphereplot, a 2 column matrix or length 2 numeric.

inverse

Logical. If TRUE, then conversion is to coordinates that can be used in spherstat. If FALSE, then converstion is to coordinates that can be used in globe (convert.globe) or sphereplot (convert.sphereplot).

sp.dim

If inverse=TRUE, takes value 2 or 3 to respectively produce a 2 or 3 column matrix. Ignored if inverse=FALSE.

Value

If inverse=FALSE, a 2 column matrix that can be plotted using functions in the package globe (if convert.globe used) or sphereplot (if , convert.sphereplot used). If inverse=TRUE, a 2 column matrix of locations in spherical coordinates (if sp.dim=2) or a 3 column matrix of locations in Cartesian coordinates (if sp.dim=3).

Note

convert.sphereplot does not need the radius of the sphere; you specify the radius when making calls to sphereplot functions suchh as rgl.sphgrid and rgl.sphpoints that plot the data. Also, if coordinates are converted using either function, and then converted back again with the same function, the doubly converted coordinates may differ from the orignal coordinates by a minute quantity (i.e.~in the vicinity of 10^-16).

Author(s)

Tom Lawrence <email:tjlawrence@bigpond.com>

See Also

convert2, convert3

Examples

sphere <- sphwin(type="sphere")
X <- rpoispp.sphwin(win=sphere, lambda=150)
X.sphereplot <- convert.sphereplot(X)
if(require(sphereplot)) {
  rgl.sphgrid(longtype="D")
  rgl.sphpoints(long=X.sphereplot, radius=1)
Xback <- convert.sphereplot(X.sphereplot, inverse=TRUE, sp.dim=2)
}
if(require(globe)) {
X <- rpoispp.sphwin(win=sphere, lambda=150, rad=1)
X.globe <- convert.globe(X)
globeearth(eye=place("northpole"), top=place("nedlands"))
globepoints(loc=X.globe, eye=place("northpole"), top=place("nedlands"))
Xback <- convert.globe(X.globe, inverse=TRUE, sp.dim=3)
}

baddstats/spherstat documentation built on Feb. 6, 2023, 1:45 a.m.