0

I want something like this: to add layers to the bottom of a 3d map and be able to display it in layers one below the other. The first map will be the population density map. The second layer will be a map with the county boundaries visible. I want it to appear with distance between them, not in a nested state. I used the "render_polygons" function for this. but i couldn't get exactly the result i wanted. Is there a function or solution you can suggest me?

# plotting 3D

try(rgl::close3d())

pop_matrix %>%
  height_shade(texture = texture) %>%
  plot_3d(heightmap = pop_matrix,
          zscale = 250 / 2.5,
          solid = F,
          shadow =FALSE)

render_camera(theta = 10,
              phi = 35,
              zoom = 0.6,
              fov = 90
)


# adding the district layer to the bottom of the map as a layer

render_camera(theta=10,  phi=35, zoom = 0.6, fov=90)
render_polygons(mont_county_buff, 
                extent = attr(delhi_raster,"extent"), bottom = -650, top=-653,
                alpha = 0.6,
                color = "#e69c6b", parallel=TRUE, clear_previous=TRUE)

# Visualization of the first layer
render_polygons(pop_matrix, 
                extent = attr(delhi_raster,"extent"), 
                bottom = 0, 
                top = 250, 
                color = "gray",
                clear_previous = TRUE)

# Visualization of the second layer
render_polygons(mont_county_buff, 
                extent = attr(delhi_raster,"extent"), 
                bottom = -650, 
                top = -653,
                color = "#FBE3C2",
                alpha = 0.8,
                clear_previous = TRUE)

outfile <- "path"

{
  start_time <- Sys.time()
  cat(crayon::cyan(start_time), "\n")
  if(!file.exists(outfile)) {
    png::writePNG(matrix(1), target = outfile)
  } 
  render_highquality(
    filename = outfile,
    interactive = F,
    lightdirection = 225,
    lightaltitude = c(20, 80),
    lightcolor = c(color[2], "white"),
    lightintensity = c(600, 100),
    width = 1980,
    height = 1080,
    samples = 200
  )
  
  end_time <- Sys.time()
  diff <- end_time - start_time
  cat(crayon::cyan(diff), "\n")
}

Output:

enter image description here

I was able to add layers one under the other here, but the problem is: even though I have specified the color of the underlying map, it appears in another color. also the county boundaries are not clear (it was visible in the rgl window though). The second problem is that even though I specify the background color, it comes as black. How can I fix this.

Appreciate any help.

datasever
  • 37
  • 4
  • You should make your code reproducible by using only datasets included with packages, or code to simulate data. One should be able to copy and paste your code and run it on their own machine. – fisher-j Apr 25 '23 at 17:43

0 Answers0