copy_down: Copy down values to vertices

View source: R/copy_down.R

copy_downR Documentation

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 class 'mesh3d'
copy_down(x, z = NULL, ..., .id = "z_")

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

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

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

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

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

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

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

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

## S3 method for class '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_"

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.

Value

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

Examples

library(raster)
r <- raster(volcano)
cl <- silicate::SC(rasterToContour(r))
plot3d(copy_down(cl, r))
## looks funny?
auto_3d()


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


hypertidy/rangl documentation built on Nov. 24, 2022, 10:29 p.m.