Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sphere 3D #3

Closed
courtiol opened this issue Sep 14, 2016 · 2 comments
Closed

Sphere 3D #3

courtiol opened this issue Sep 14, 2016 · 2 comments
Assignees

Comments

@courtiol
Copy link
Owner

courtiol commented Sep 14, 2016

I looked at how one could make nice 3D geospheres in R using rgl.
The following site does not tell the details but the results are stunning, so I really want to add this possibility in the package at some point :-)

link1
link2

It is not that difficult once one has the png of the entire map, I am struggling however to extract the central part of the lattice plots (i.e. the map itself, without the axes, keys, margins...). I want the area selected by trellis.focus()...

Once this will be solved, then the following works:

library(rgl)
map <- rgl.spheres(0, texture="map.png", lit=FALSE)
## for gif movie
movie3d(spin3d(axis = c(0, 1, 0), rpm=2), duration = 30, dir = getwd())
@courtiol
Copy link
Owner Author

Try something inspired by that (from Deepayan Sarkar deepayan.sarkar@r-project.org ):

library(grid)
library(lattice)

p <- levelplot(volcano)
pargs <- trellis.panelArgs(p, 1)
lims <- do.call(prepanel.default.levelplot, pargs)
str(lims) # viewport scales

Need f = 0.07 below (for reasons that are not important)

grid.newpage()
pushViewport(viewport(xscale = extendrange(lims$xlim, f = 0.07),
yscale = extendrange(lims$ylim, f = 0.07)))
do.call(panel.levelplot, pargs)

@courtiol
Copy link
Owner Author

Another way using the package mapmate looks very promising (but potentially slow): https://www.r-bloggers.com/spinning-globes-with-r/

We need to try that too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants