Description Usage Arguments Value Examples
Takes a rasterstack or a path to a NetCDF file and generates 3D vizualisations from the data, offering a couple of options (e.g. flat or spherical viz; interpolation between layers). The values can be either represented as colors and height, or the height can be specified by a separate (static) raster.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | brick2movie(
brick = br,
eleRast = globalDEM0.5deg,
eleRastOnly4NA = TRUE,
renderOcean = FALSE,
renderSphere = FALSE,
useRayShade4Sphere = FALSE,
renderFakeSphere = FALSE,
sphereExtFac = 0.2,
renderCountries = FALSE,
minVal = NULL,
maxVal = NULL,
nudgeMin2ZeroElev = F,
maxFac = 1,
gaussianSmoothSigma = 0,
zscaleRatio = 40,
col4NA = "white",
elevat4NA = 0,
oceanCol = "paleturquoise",
nSubSteps = 1,
rewindLoop = F,
loop = 0,
append1st = TRUE,
outPrefix = "Animation",
outFolder = tempdir(),
framerate = 8,
titles = NULL,
justReRenderVideo = FALSE,
renderVideo = TRUE,
renderLegend = TRUE,
leg.tit = expression(g ~ C ~ ~m^{ -2 } ~ day^{ -1 }),
caption = "",
resume = FALSE,
nRounds = 1,
thetaStartEnd = c(0, 0),
phiStartEnd = c(0, 0) + 45 * !renderSphere,
cntStart = 0,
over = NULL,
useOnlyOver = FALSE,
over2 = NULL,
pal = palette(),
...
)
|
brick |
The rasterStack or brick to be visualized. Default: br brick in this package |
eleRast |
The raster to be used for elevation. Default: globalDEM0.5deg in this package |
eleRastOnly4NA |
Should the elevation raster only be used in case of NA in the |
renderOcean |
Should the ocean be rendered (with a blue transparent)? Default: FALSE |
renderSphere |
Should the data set be rendered as a sphere? Default: FALSE |
useRayShade4Sphere |
Should the rayshader flat image (e.g. including shadows) be used as texture for the spherical viz? Default: TRUE |
renderFakeSphere |
Should the rayshader flat image just wrapped around the sphere without elevation effects. Not recommended. Default: FALSE |
sphereExtFac |
Indicates how pronouned the elevation should be. 0 = no elevation effect, 1 = range of elevations is radius of the sphere. Default: 0.2 |
renderCountries |
Should the country borders be rendered? Default: FALSE |
minVal |
Set manually the minimum value in the brick for color and elevation scaling. If not set, will be derived from data, but it seems brick need to be in memory then! |
maxVal |
Set manually the maximum value in the brick for color and elevation scaling. If not set, will be derived from data, but it seems brick need to be in memory then! |
nudgeMin2ZeroElev |
If TRUE, the minimum elevation from the data will be set to zero (= Ocean level). Default= FALSE |
maxFac |
Can be used to reduce the maximum to stretch color scale and elevation (e.g. if derived from range of data). Default: 1.0 |
gaussianSmoothSigma |
If >0, applies a spatial Gaussian smoothing with sigma. Default: 0 |
zscaleRatio |
The elevetation range to pixel size will be this ratio. Default: 40 (i.e. height is 40 times the pixel size) |
col4NA |
COlor used for NA. Default: "white" |
elevat4NA |
The elevation to be the used if NA. Default: 0 |
oceanCol |
COlor of the ocean. Default: "paleturquoise" |
nSubSteps |
Substeps (Interpolation in time) per layer (to make animation smoother). 1 means no interpolation. Default: 2 |
rewindLoop |
Should, for the animation, the sequence by reversed (forth and back). Default: FALSE |
loop |
How many loops should be rendered in the animation. Default: 0 |
append1st |
Should the first layer be appended? Helpful to make a smooth seasonal cycle. Default: TRUE |
outPrefix |
Name of the subfolder and prefix of output file name. Default: "Animation" |
outFolder |
Folder where results are written. Default: tempdir() |
framerate |
Video framerate. Default: 8 |
titles |
Vector of title of length number of layers: Default: NULL |
justReRenderVideo |
Should just the video be (re-)rendered (e.g. with different framerate; then pngs must be there already). Default: FALSE |
renderVideo |
Should a video be rendered? Default: TRUE |
renderLegend |
Should a color legend be rendered= Default: TRUE |
leg.tit |
Title of the legend, intended to contain the unit Default: |
caption |
Caption of pngs and video. Default: "" |
resume |
Should the process just be resumed (then files in folder will not be overwritten, but rather continued). Default: FALSE |
nRounds |
One round is going once through all layers. Several rounds makes sense if combined with varying view angles. Default: 1 |
thetaStartEnd |
Start and end view horizontal angle. Default: C(0,0) |
phiStartEnd |
Start and end vertical angle: Default: |
cntStart |
Can change where the file number counting starts. Default: 0 |
over |
An overlay to be plotted. Can be an filepath to an image, or SpatialPolygonDataFrame from wihch an overlay image is generated with |
useOnlyOver |
If TRUE only the overlay is used in the spherical rendering and br data ignored. Otherwise the texture is "somehow" combined with the plotcolor in |
over2 |
Can be another overlay image. Default: NULL |
pal |
The palette to be used. Vector of colors. Default: |
... |
parameters passed on to other functions |
Returns an array of generated files (so that can used in pipe with renderVideos
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ## Create pngs for animation of maps on a sphere
## Open an rgl window with defined size first
rgl::open3d(windowRect = 50 + c(0,0,1920,1080))
## Just a single frame br[[6]] for brevity (br is a brick with 12 layers)
## Simple sphere without elevation model and ocean
brick2movie(br[[6]], eleRast = NULL, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=T, pal=rev(pal_MR$divViriMagma))
## Sphere with elevation model and ocean
brick2movie(br[[6]], eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=T, renderOcean=T, pal=rev(pal_MR$divViriMagma))
## Same but now a flat projection
brick2movie(br[[6]], eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=F, renderOcean=T, pal=rev(pal_MR$divViriMagma))
## Now an animation with interpolation and 10 rounds and include country borders
## This creates 480 frames ==> takes a bit of time
brick2movie(br, eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = T, renderSphere=T, renderOcean=T, pal=rev(pal_MR$divViriMagma), renderCountries = T, thetaStartEnd = c(0,360), nSubSteps = 4, nRounds = 10)
## The same but flat ==> just change rendersphere to 'F'
brick2movie(br, eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = T, renderSphere=F, renderOcean=T, pal=rev(pal_MR$divViriMagma), renderCountries = T, thetaStartEnd = c(0,360), nSubSteps = 4, nRounds = 10)
## Also works for regions
africa <- crop(br, extent(-23.906250,55.458984, -37.889187,39.364140) )
## Flat
brick2movie(africa[[6]], eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=F, renderOcean = T, renderCountries = T, pal=rev(pal_MR$divViriMagma))
## Sphere
brick2movie(africa[[6]] %>% raster::disaggregate(2), eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=T, renderOcean = T, renderCountries = T, pal=rev(pal_MR$divViriMagma))
## Or with projections
prj <- projGlobal$Robinson
brick2movie(br[[6]] %>% aggregate(2) %>% terra::rast() %>% terra::project(prj, mask=T) %>% raster(), eleRast = globalDEM0.5deg, gaussianSmoothSigma = 1, renderVideo = F, renderSphere=F, renderOcean = T, renderCountries = T, pal=rev(pal_MR$divViriMagma), phiStartEnd = c(50,50), elevat4NA = NA, title=paste("June GPP", prj ))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.