
R version 2.15.1 (2012-06-22) -- "Roasted Marshmallows"
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-unknown-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> suppressPackageStartupMessages(library(rgdal))
> data(state)
> xy <- cbind(state.center$x, state.center$y)
> res <- project(xy, "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100")
> res1 <- project(res, "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100", inv=TRUE)
> stopifnot(isTRUE(all.equal(res1, xy)))
> crds <- matrix(data=c(9.05, 48.52), ncol=2)
> a <- project(crds, paste("+proj=ob_tran +o_proj=longlat",
+  "+o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs"),
+  use_ob_tran=TRUE)
> stopifnot(isTRUE(all.equal(a, matrix(c(-5.917698, -1.87195), ncol=2), tolerance=.Machine$double.eps ^ 0.25)))
> a1 <- project(a, paste("+proj=ob_tran +o_proj=longlat",
+  "+o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs"),
+  inv=TRUE, use_ob_tran=TRUE)
> stopifnot(isTRUE(all.equal(a1, crds, tolerance=.Machine$double.eps ^ 0.25)))
> states <- data.frame(state.x77, state.center)
> states <- states[states$x > -121,]
> coordinates(states) <- c("x", "y")
> proj4string(states) <- CRS("+proj=longlat +ellps=clrk66")
> state.ll83 <- spTransform(states, CRS("+proj=longlat +ellps=GRS80"))
> state.ll <- spTransform(state.ll83, CRS("+proj=longlat +ellps=clrk66"))
> stopifnot(isTRUE(all.equal(coordinates(states), coordinates(state.ll))))
> spPoint <- SpatialPoints(coords=crds,
+  proj4string=CRS("+proj=longlat +ellps=sphere +no_defs"))
> a <- spTransform(spPoint, CRS(paste("+proj=ob_tran +o_proj=longlat",
+  "+o_lon_p=-162 +o_lat_p=39.25 +lon_0=180 +ellps=sphere +no_defs")),
+  use_ob_tran=TRUE)
> stopifnot(isTRUE(all.equal(unname(coordinates(a)), matrix(c(-5.917698, -1.87195), ncol=2), tolerance=.Machine$double.eps ^ 0.25)))
> a1 <- spTransform(a, CRS("+proj=longlat +ellps=sphere +no_defs"),
+  use_ob_tran=TRUE)
> stopifnot(isTRUE(all.equal(unname(coordinates(a1)), unname(coordinates(spPoint)), tolerance=.Machine$double.eps ^ 0.25)))
> 
> 
> proc.time()
   user  system elapsed 
  0.674   0.088   0.743 
