Learn R Programming

anglr (version 0.7.0)

copy_down: Copy down values to vertices

Description

Copy down provides ways to transfer object level data values to vertex level.

Usage

copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for mesh3d copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for SC copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for SC0 copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for TRI copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for TRI0 copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for PATH copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for PATH0 copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for ARC copy_down(x, z = NULL, ..., .id = "z_")

# S3 method for QUAD copy_down(x, z = NULL, ..., .id = "z_")

Arguments

x

a mesh3d or a silicate object

z

object specifying values to copy down, a vector of values, a column name, a raster (see details)

...

currently ignored

.id

character value, the name of the resulting column in the vertices, default is "z_"

Value

a mesh3d or silicate model with vertex values copied to vertices (depending on the input argument 'x')

Details

Various methods are used depending on the second argument z.

If z is a raster (BasicRaster) a numeric value for each vertex is found by bilinear interpolation using raster::extract(raster, vertex, method = "bilinear"). Vertices are transformed into the space used by the raster if possible.

If z is a character value, that column is taken from the object table.

The .id argument must be character and exist as a column name in the object table.

If z is a vector or a constant value it's simply copied down.

No checking is done on the type of the result, and so there's nothing to stop the use of the recycling rule to expand out values, and nothing to stop the use of non numeric values being copied down.

Use silicate::TRI0() or DEL0() or silicate::SC0() to convert various spatial formats into suitable forms for this function.

Examples

Run this code
# NOT RUN {
library(raster)
r <- raster(volcano)
cl <- silicate::SC(rasterToContour(r))
plot3d(copy_down(cl, r))
## looks funny?
auto_3d()

# }
# NOT RUN {
sc <- copy_down(SC0(cont_tas), "ELEVATION")
sc$object$color_ <- hcl.colors(nrow(sc$object), "YlOrRd")
 plot3d(sc)

 ## a planar straight line graph with x, y (UTM) and ELEVATION (metres)
 sc
# }

Run the code above in your browser using DataLab