| vol_payload | R Documentation |
Writes the directory the renderer reads: one image per depth level holding the quantised field, the image of the opaque sheet, the colour lookup image, and a manifest recording the grid, the transfer, the display defaults and a SHA-256 of every file written.
vol_payload(
field,
dir,
transfer = "auto",
display = NULL,
step = 1L,
resample = TRUE,
dz = NULL,
created = NULL,
title = NULL,
subtitle = NULL,
axes = NULL,
geographic = NULL,
depth_unit = NULL
)
field |
A |
dir |
Directory to write into. Created when absent. |
transfer |
Name of the transfer, passed to |
display |
Named list of the defaults the viewer opens with: |
step |
Horizontal decimation. 1 keeps the native grid. |
resample |
Logical. Put the depth axis on a uniform grid first, when it is not already uniform. |
dz |
Spacing of that grid, passed to |
created |
Timestamp written into the manifest. Defaults to the current time in UTC. Pin it to make two builds of one field give one set of bytes. |
title |
Heading the viewer shows. Defaults to the name of the field. |
subtitle |
Line under the heading. Defaults to the name of the field and the depth span. |
axes |
Named list with |
geographic |
Logical. When |
depth_unit |
Unit of the vertical axis, used in the readouts. Defaults to metres for a geographic field and to none for any other. |
Write the browser payload of a field
Every level is written as an 8-bit greyscale PNG, because a browser
decodes PNG natively, the format is lossless, and one image per level lets
the loader build a three-dimensional texture without any custom container.
The whole cube of the case study at its native grid, 1016 by 380 by 21,
travels in about 1.5 MB this way (vol_example_payload()).
The horizontal grid is not reduced by default, and step exists for the
cases where it must be. A block mean to half the resolution already costs
an error comparable with the width of a plotted colour band, whereas the
transfer into 8 bits costs a small fraction of one; spending the bits on
the vertical and on the value range rather than on the horizontal grid is
what keeps the payload both small and faithful.
The manifest records the SHA-256 of every file it names, and carries through the digests of the arrays the field came from when the field carries them, so a rendering can be traced back to its inputs.
An object of class vol_payload: a list with dir, manifest,
files, encoding and field.
vol_field() for the input, vol_encode() for the transfer,
vol_standalone() to carry the payload inside one HTML file,
vol_widget() to render it in shiny or R Markdown,
print.vol_payload(), summary.vol_payload() and plot.vol_payload()
for the methods.
data(med_mhw)
p <- vol_payload(med_mhw, tempfile("payload"))
p
summary(p)
plot(p)
plot(p, type = "level", depth = 50)
vol_standalone(p, path = tempfile(fileext = ".html"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.