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, ...)

Arguments

r

A raster to be plotted (see pretty_scape_3d).

aggregate

(optional) A named list of arguments that is passed to aggregate to aggregate raster cells, excluding the aggregation factor (fact), which is specified interactively.

buffer

(optional) A named list of arguments that is passed to gBuffer to add a buffer around inputted points, within which the raster is shown, except width which is set interactively.

add_markers

(optional) A named list of arguments that is passed to add_markers to add points to the plot. Of these, subsets of markers can be selected interactively to zoom into the landscape in particular areas.

...

Other arguments passed to pretty_scape_3d.

Value

The function returns an interactive R Shiny application.

Details

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.

See also

Author

Edward Lavender

Examples

#### 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"))
#> Warning: Discarded datum Unknown based on WGS84 ellipsoid in CRS definition
#### 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 if (FALSE) { # Only run examples in interactive R sessions if(interactive()){ vis_scape_3d(r = dat_gebco_utm) } } #### 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. if (FALSE) { if(interactive()){ vis_scape_3d(r = dat_gebco_utm, aggregate = list(fun = mean) ) } } #### Example 3: Zoom around inputted markers interactively if (FALSE) { 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) ) } } #### Example 4: Other arguments can be passed to pretty_scape_3d() via ... if (FALSE) { if(interactive()){ vis_scape_3d(r = dat_gebco_utm, aspectmode = "data" ) } } # However, note that inputting arguments to pretty_scape_3d() that are set by the Shiny # ... interactively will cause an error: if (FALSE) { if(interactive()){ vis_scape_3d(r = dat_gebco_utm, stretch = 10 ) } }