Plot levitating object in rayshader

69 Views Asked by At

I'd like to create sort of levitating objects with rayshader, but I don't know how to do so.

Here's an example:

test <- structure(list(id = c(1, 2), hauteur = c(10, 20), geometry = structure(list(
    structure(list(structure(c(-1.36168948095423, -1.36169305908512, 
    -1.36002570022701, -1.36004117161482, -1.35912195131564, 
    -1.35914242955086, -1.35844923534243, -1.35839833680255, 
    -1.36168948095423, -5.9860092862187, -5.98515370941195, -5.98506767037104, 
    -5.98478743024393, -5.98471158140101, -5.98501879708984, 
    -5.98503042065794, -5.98583965411611, -5.9860092862187), .Dim = c(9L, 
    2L))), class = c("XY", "POLYGON", "sfg")), structure(list(
        structure(c(-1.36155282525813, -1.36162688579707, -1.36039531642929, 
        -1.36034993206991, -1.35927629531794, -1.35922529091398, 
        -1.35867417902484, -1.35873070423009, -1.36155282525813, 
        -5.98803180168874, -5.98714267345713, -5.98707450596375, 
        -5.98665348482721, -5.98666278591778, -5.98713469051296, 
        -5.9872853456686, -5.98795683043924, -5.98803180168874
        ), .Dim = c(9L, 2L))), class = c("XY", "POLYGON", "sfg"
    ))), n_empty = 0L, crs = structure(list(input = "WGS 84", 
    wkt = "GEOGCRS[\"WGS 84\",\n    DATUM[\"World Geodetic System 1984\",\n        ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n            LENGTHUNIT[\"metre\",1]]],\n    PRIMEM[\"Greenwich\",0,\n        ANGLEUNIT[\"degree\",0.0174532925199433]],\n    CS[ellipsoidal,2],\n        AXIS[\"latitude\",north,\n            ORDER[1],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n        AXIS[\"longitude\",east,\n            ORDER[2],\n            ANGLEUNIT[\"degree\",0.0174532925199433]],\n    ID[\"EPSG\",4326]]"), class = "crs"), class = c("sfc_POLYGON", 
"sfc"), precision = 0, bbox = structure(c(xmin = -1.36169305908512, 
ymin = -5.98803180168874, xmax = -1.35839833680255, ymax = -5.98471158140101
), class = "bbox"))), row.names = c(NA, -2L), class = c("sf", 
"data.frame"), sf_column = "geometry", agr = structure(c(id = NA_integer_, 
hauteur = NA_integer_), class = "factor", .Label = c("constant", 
"aggregate", "identity")))

Code:

library(ggplot2)
library(rayshader)

metro <- ggplot(test, aes(fill = hauteur)) +
  geom_sf() +
  theme_bw()

plot_gg(metro)

enter image description here

enter image description here

As you can see in the rayshader plot, the height dimension starts at 10 while I'd like it to strart from another level, such as 15 for example, so it give the impression one of the two object is flying, while the other is still "on the ground".

Thanks for your help!

0

There are 0 best solutions below