vis_scape_3d | R Documentation |
This function uses pretty_scape_3d
in an interactive R Shiny environment to facilitate the rapid exploration of complex environments. This is particularly useful if you want to zoom into the landscape around different points.
vis_scape_3d(r, aggregate = NULL, buffer = NULL, add_markers = NULL, ...)
r |
A |
aggregate |
(optional) A named list of arguments that is passed to |
buffer |
(optional) A named list of arguments that is passed to |
add_markers |
(optional) A named list of arguments that is passed to |
... |
Other arguments passed to |
The R Shiny interface provides the following interactive options: (a) zoom around (interactively selected subsets of) inputted points, (b) aggregate the raster, (c) add planes at different heights, and stretch the raster vertically according to interactively specified options. The following function arguments are inputted interactively and should not be inputted via the function call: buffer$width
, aggregate$fact
, plane
and stretch
. To zoom around inputted points, you must specify add_markers
. The width
option to buffer
is set interactively and should not be provided. To aggregate the raster, at least one argument must be supplied to aggregate
(e.g. fun
). The fact
option is set interactively and should not be provided. In all cases, arguments to plan
and stretch
are set interactively, so these options should not be included in the function call. Other customisation arguments, passed to pretty_scape_3d
, can be included in the function call.
The function returns an interactive R Shiny application.
Edward Lavender
pretty_scape_3d
#### Use UTM raster for visualisation
# This is best for visualisation because x, y and z coordinates are on the same scale (m)
# Planar coordinates coordinates are also required to zoom around points (see ?rgeos::gBuffer)
dat_gebco_utm <- raster::projectRaster(dat_gebco, crs = sp::CRS("+proj=utm +zone=29 ellps=WGS84"))
#### Example 1: Only supply a raster
# In this case, the two benefits of the Shiny, relative to pretty_scape_3d(), are
# ... (a) interactive adjustment of vertical stretch
# ... (b) interactive addition of horizontal planes
## Not run:
# Only run examples in interactive R sessions
if(interactive()){
vis_scape_3d(r = dat_gebco_utm)
}
## End(Not run)
#### Example 2: Interactive raster aggregation
# To implement this, you need to directly specify at least one argument
# ... for raster::aggregate, such as the function, fun, via vis_scape_3d()'s aggregate argument.
# ... The aggregation fact is set interactively. Note that you will get a warning
# ... initally because the default aggregation fact is 1, i.e., no aggregation.
## Not run:
if(interactive()){
vis_scape_3d(r = dat_gebco_utm,
aggregate = list(fun = mean)
)
}
## End(Not run)
#### Example 3: Zoom around inputted markers interactively
## Not run:
if(interactive()){
# Define example coordinates on UTM scale
xyz <- matrix(raster::coordinates(dat_gebco_utm)[500:520, ], ncol = 2)
xyz <- data.frame(x = xyz[, 1], y = xyz[, 2], z = -10)
# Lauch application and interactively define buffer size in m
# Note that you will may a warning initally because the default buffer size is small.
vis_scape_3d(r = dat_gebco_utm,
add_markers = list(x = xyz$x, y = xyz$y, z = xyz$z)
)
}
## End(Not run)
#### Example 4: Other arguments can be passed to pretty_scape_3d() via ...
## Not run:
if(interactive()){
vis_scape_3d(r = dat_gebco_utm,
aspectmode = "data"
)
}
## End(Not run)
# However, note that inputting arguments to pretty_scape_3d() that are set by the Shiny
# ... interactively will cause an error:
## Not run:
if(interactive()){
vis_scape_3d(r = dat_gebco_utm,
stretch = 10
)
}
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.