writeRasterToVTK: Write a 2D raster to XDMF XML wrapper and binary data file.

Description Usage Arguments Details Value Author(s) Examples

View source: R/mkdeFunctions.R

Description

Write the raster to a XDMF files.

Usage

1
writeRasterToVTK(elev, r.rst, g.rst, b.rst, descr, fname)	

Arguments

elev

A RasterLayer object

r.rst

A RasterLayer object for red

g.rst

A RasterLayer object for green

b.rst

A RasterLayer object for blue

descr

String description to be added to header of VTK file

fname

The path and base file name for output HDF5 files

Details

This function writes a raster to VTK format. The raster is colored according to the RGB values in r.rst, g.rst, and b.rst, respectively. The RGB balues must be an interger from 0 to 255.

Value

No value is returned

Author(s)

Jeff A. Tracey, PhD
USGS Western Ecological Research Center, San Diego Field Station
[email protected]
James Sheppard, PhD
San Diego Zoo Institute for Conservation Research
[email protected]
Amit Chourasia, MS
San Diego Supercomputer Center
[email protected]

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
library(raster)
data(condordem120)
elev.val <- values(condordem120)
elev.min <- min(elev.val, na.rm=TRUE)
elev.max <- max(elev.val, na.rm=TRUE)

# make a color lookup table
cmap <- data.frame(value=c(0.0, 0.25, 0.5, 0.75, 1.0), 
  R=c(150, 179, 205, 192, 252), 
  G=c(224, 204, 205, 183, 243), 
  B=c(94, 147, 168, 147, 226))
                    
cmap$value <- cmap$value*(elev.max - elev.min) + elev.min
# red
f.R <- approxfun(cmap$value, cmap$R)
elev.r <- raster(condordem120)
values(elev.r) <- round(f.R(elev.val))
# green
f.G <- approxfun(cmap$value, cmap$G)
elev.g <- raster(condordem120)
values(elev.g) <- round(f.G(elev.val))
# blue
f.B <- approxfun(cmap$value, cmap$B)
elev.b <- raster(condordem120)
values(elev.b) <- round(f.B(elev.val))
writeRasterToVTK(condordem120, elev.r, elev.g, elev.b, "Elevation for
California condor Example", "condor_dem.vtk")

mkde documentation built on May 29, 2017, 8:26 p.m.