Plot the stand in 3D

Share:

Description

Reads the MAESTRA trees file, and plots the stand in 3D. Supports all MAESTRA crown shapes except the box shape. Looks for the 'trees.dat' file in the current working directory, unless specified (see Examples). The XY coordinates *must be present* in the 'trees.dat' file. Users will typically only use the 'Plotstand' function.

Optionally reads the crown shape from the 'str.dat' file, and plots the correct crown shape for each species in the stand by reading the multi-species namelists in 'confile.dat' and 'trees.dat'.

The target trees are colored red (unless specified otherwise, see Details), if the 'itargets' is specified in the confile.

Attempts to read indivradx, indivrady, indivhtcrown, indivdiam, and indivhttrunk namelists from the 'trees.dat' file. If any of these fail, the 'all' versions are tried ('allradx', etc.). Although MAESTRA runs fine when no XY coordinates are provided, this plot function crashes. A future implementation will calculate XY coordinates in the same way as MAESTRA.

If the 'strfiles' parameter is set in 'confile.dat' (one str.dat file for each species in the stand), these files are opened and used to set the crown shape by species. Alternatively, you may specify crownshape as a parameter, and override reading of str.dat by setting readstrfiles=FALSE.

The 'nz' and 'nalpha' arguments specify the 'smoothness' of the crowns: higher values provide more detailed triangulation of the crowns, at the expense of speed.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Plotstand(treesfile = "trees.dat", strfile = "str.dat",
  crownshape = c("cone", "ellipsoid", "round", "halfellipsoid", "paraboloid",
  "cylinder"), readstrfiles = TRUE, targethighlight = TRUE,
  addNarrow = TRUE, xyaxes = TRUE, labcex = 1, axiscex = 1,
  verbose = FALSE, idate = 1, path = "", ...)

plottree(crownshape = c("cone", "elipsoid", "ellipsoid", "round",
  "halfellipsoid", "paraboloid", "cylinder"), CL = 1, CW = 1, HCB = 1,
  X = 0, Y = 0, dbh = 0.3, crowncolor = "forestgreen",
  stemcolor = "brown", nz = 25, nalpha = 25, ...)

Arguments

treesfile

By default, the 'trees.dat' file in the current dir.

strfile

Not used, yet.

crownshape

Character, "cone","elipsoid","ellipsoid","halfellipsoid","paraboloid","cylinder", or abbreviation.

readstrfiles

Read the 'str.dat' file(s) to find out crown shape?

targethighlight

Plot the target trees in red?

addNarrow

Logical. Add arrow pointing North?

xyaxes

Logical. Add annotated X and Y axes?

labcex

Relative size of X and Y axis labels.

axiscex

Relative size of X and Y axis annotation.

verbose

If TRUE, writes more info to the screen while plotting.

idate

If multiple dates are provided for tree size variables, which one to display.

path

The folder where the input files are stored.

CL

Crown length (m).

CW

Crown width (m).

HCB

Height of crown base (m).

X,Y

X- and Y-coordinates of tree stem base (m).

dbh

Stem diameter (m). Converted to m if appears to be in cm.

crowncolor

The color of the tree crowns. Default, obviously, 'forestgreen'.

stemcolor

The color of the tree stems. Default 'brown'.

nz

Number of z divisions (increase number to get smoother crowns).

nalpha

Number of angular divisions (increase number to get smoother crowns).

...

Further parameters passed (to plottree, or triangles3d).

Details

For large stands, the plot takes quite a while to complete. This code is far from optimized for speed, because I am patient. Also, minimize the rgl window to greatly speed it up.

Value

An rgl device is opened.

Author(s)

Remko Duursma

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## Not run: 

# Plot the 'trees.dat' file in the current working directory:
Plotstand()

# Open a dialog box to select a trees.dat file:
Plotstand(file.choose())

# Save a snapshot to a .png file.
# Note: make sure to move the 3D plot into view
# (so that other windows are not blocking it!)
snapshot3d('myforest.png')

# For publication-quality graphs:
Plotstand(nz=50, nalpha=50)



## End(Not run)