How to add a map on the bottom of a 3D plot in R

101 Views Asked by At

In the below example case I would like to have a geographical map plotted on the lat-long -plane underneath the intersecting 2D profiles.

The use of packages 'plot3D' or 'maps' is not necessary.

  library(plot3D)

  alt <- rev(seq(0, 500, 5))
  lat <- seq(30, 65, 0.25)
  long <- seq(-135, -65, 0.5)

  grid <- mesh(long, lat, alt)
  names(grid) <- c("long", "lat", "alt")
  colvar <- with(grid, dnorm(long, -100, 20) * 
                       dnorm(lat, 50, 10) *
                       dnorm(alt, 250, 100))

  colvar <- colvar/max(colvar)

  slice3D (long, lat, alt, 
           colvar = colvar,
           ys  = 50, xs = -100, zs = NULL,
           xlab = "long",
           ylab = "lat",
           zlab = "alt",
           theta = 60, phi = 40,
           ticktype = "detailed")

Example map:

library(maps)
plot(NULL, xlim = range(long), ylim = range(lat), 
     xlab = "long", ylab = "lat")
map("world", add = TRUE)

enter image description here

enter image description here

0

There are 0 best solutions below