0

I have several things that I want to combine into one plot. I have a DEM that I want to use as the base, a polygon layer that I want over the DEM and then a point layer over top of that.

The idea is that I want to plot everything using Rayshader so that the DEM layer is in 3D, that the polygons are colored based on an attribute and then on top of that I would like to plot the point layer as columns. I have been struggling for this for a while now and this is where I have gotten so far using this code:


#Reading in dem file

DEM <- raster("NRW_dem2.tif")

dem <- as.data.frame(DEM, xy=TRUE)


#Reading in shapefile
shp <- readOGR( dsn =".", layer = "NRW_dominant_species", stringsAsFactors = F)

#Reading in data
data <- read.csv("NRW_growing_stock_BAU.csv")

#Reading points
plots <- read.csv("NRW_plots.csv")

plots <- plots %>% dplyr::rename(plot = tmt.plot.id)

data <- left_join(data, plots, by="plot", all.x=TRUE) #getting coordinates

#Combine dem, species and growing stock
p3 <- ggplot() +
  geom_raster(data = dem, aes(x=x, y=y, fill=layer)) +
  geom_sf(data = shp, fill = shp$DN) +
  geom_point(data = data, aes(x = longitude, y = latitude,color=volume_per_ha), size=1.5, inherit.aes = FALSE)

p3

enter image description here

As you can tell, the 3D effect is used by the shapefile instead of the DEM and the point layer is not on top of the other layers, is there anyway to accomplish this or not?

starski
  • 141
  • 6

0 Answers0