Learn R Programming

oce (version 0.9-18)

map2lonlat: Convert from x-y to longitude and latitude

Description

Convert from x-y coordinates to longitude and latitude. This is normally called internally within oce; see Bugs.

Usage

map2lonlat(x, y, init=c(0,0))

Arguments

x
a vector containing the x component of points in the projected space, or a list containing items named x and y, in which case the next argument is ignored.
y
a vector containing the y coordinate of points in the projected space (ignored if x is a list, as described above).
init
a vector containing the initial guesses for longitude and latitude, presently ignored.

Value

  • A list containing longitude and latitude, with NA values indicating points that are off the globe as displayed.

Bugs

oce uses project in the rgdal package to handle projections. Only those projections that have inverses are permitted within oce, but this does not mean that all data can be inverted with map2lonlat. For example, as of June 2015, the rgdal version of the Winkel Tripel projection (from mapPlot(, ..., projection="+proj=wintri", ...)) handles "off globe" data poorly, either taking what seems to be an infinite time to do the calculation, or even crashing R. This is due to a loop in the rgdal C code (file PJ_aitoff.c) failing to converge for "off globe" points. Not all setups have this difficulty, however, and since the problem was reported to the PROJ.4 team (email exchanges from April 10 to April 13, 2015), one can hope for a PROJ.4 solution sometime in 2015, propagating to R and thereafter rgdal in due course.

Details

A projection must already have been set up, by a call to mapPlot or lonlat2map. It should be noted that not all projections are handled well; see Bugs.

See Also

lonlat2map does the inverse operation.

Examples

Run this code
library(oce)
## Cape Split, in the Minas Basin of the Bay of Fundy
cs <- list(longitude=-64.49657,latitude=45.33462)
xy <- lonlat2map(cs, projection="+proj=merc")
map2lonlat(xy)

Run the code above in your browser using DataLab