Adds/replaces static site characteristics (topography, geology, ...) to plot elements of a VegX object from a data frame where rows are plots.

addSiteCharacteristics(
  target,
  x,
  mapping,
  measurementMethods = list(),
  missing.values = c(NA, ""),
  verbose = TRUE
)

Arguments

target

The initial object of class VegX to be modified

x

A data frame where each row corresponds to one plot observation. Columns can be varied.

mapping

A named list whose elements are strings that correspond to column names in x. Names of the list should be:

  • plotName - A string identifying the vegetation plot within the data set (required).

  • subPlotName - A string identifying a subplot of the plot given by plotName (optional).

  • slope - Slope of the plot (optional).

  • aspect - Aspect (i.e. orientation) of the plot (optional).

  • landform - Site land form (e.g. slope, ridge, saddle point; optional).

  • parentMaterial - Underlying geological material (generally bedrock or a superficial or drift deposit) in which soil horizons form. (optional).

measurementMethods

A named list of objects of class VegXMethodDefinition with the measurement method for each of the site variables stated in mapping. List names should be the same as the names of site variables (e.g. list(aspect = aspectMeth) to specify the use of method aspectMeth for aspect measurements). Alternatively, methods can be specified using strings if a predefined method exists (e.g. list(aspect = "Aspect/degrees")), see predefinedMeasurementMethod.

missing.values

A character vector of values that should be considered as missing observations/measurements.

verbose

A boolean flag to indicate console output of the data integration process.

Value

The modified object of class VegX.

Details

Named elements in mapping other than those used by this function will be ignored. Missing value policy:

  • Missing plotName values are interpreted as if the previous non-missing value has to be used to define plot.

  • Missing subPlotName values are interpreted in that data refers to the parent plotName.

  • Missing measurements (e.g. aspect, slope,...) are simply not added to the Veg-X document.

References

Wiser SK, Spencer N, De Caceres M, Kleikamp M, Boyle B & Peet RK (2011). Veg-X - an exchange standard for plot-based vegetation data

Examples

# Load source data
data(mokihinui)

# Define mapping
sitemapping = list(plotName = "Plot", subPlotName = "Subplot",
                   slope = "PlotSlope", aspect = "PlotAspect")


# Create new Veg-X document with site characteristics
x = addSiteCharacteristics(newVegX(), moki_site, mapping = sitemapping,
                           measurementMethods = list(slope = "Slope/degrees", 
                                                     aspect = "Aspect/degrees"))
#>  Measurement method 'Slope/degrees' added for 'slope'.
#>  Measurement method 'Aspect/degrees' added for 'aspect'.
#>  25 plot(s) parsed, 25 new plot(s) added.
#>  25 record(s) parsed.
#>  40 measurement(s) with missing value(s) not added.

# Inspect the result
showElementTable(x, "plot")
#>     plotName  slope_method slope_value  aspect_method aspect_value
#> 1     LGM08r Slope/degrees          40 Aspect/degrees          360
#> 2  LGM08r_1Q          <NA>          NA           <NA>           NA
#> 3  LGM08r_2Q          <NA>          NA           <NA>           NA
#> 4  LGM08r_3Q          <NA>          NA           <NA>           NA
#> 5  LGM08r_4Q          <NA>          NA           <NA>           NA
#> 6     LGM16l Slope/degrees           6 Aspect/degrees          255
#> 7  LGM16l_1Q          <NA>          NA           <NA>           NA
#> 8  LGM16l_2Q          <NA>          NA           <NA>           NA
#> 9  LGM16l_3Q          <NA>          NA           <NA>           NA
#> 10 LGM16l_4Q          <NA>          NA           <NA>           NA
#> 11    LGM38h Slope/degrees          45 Aspect/degrees          155
#> 12 LGM38h_1Q          <NA>          NA           <NA>           NA
#> 13 LGM38h_2Q          <NA>          NA           <NA>           NA
#> 14 LGM38h_3Q          <NA>          NA           <NA>           NA
#> 15 LGM38h_4Q          <NA>          NA           <NA>           NA
#> 16    LGM45h Slope/degrees          39 Aspect/degrees            5
#> 17 LGM45h_2Q          <NA>          NA           <NA>           NA
#> 18 LGM45h_3Q          <NA>          NA           <NA>           NA
#> 19 LGM45h_4Q          <NA>          NA           <NA>           NA
#> 20    LGM43h Slope/degrees          21 Aspect/degrees          260
#> 21 LGM43h_1Q          <NA>          NA           <NA>           NA
#> 22 LGM43h_2Q          <NA>          NA           <NA>           NA
#> 23 LGM43h_3Q          <NA>          NA           <NA>           NA
#> 24 LGM43h_4Q          <NA>          NA           <NA>           NA
#> 25 LGM45h_1Q          <NA>          NA           <NA>           NA
#>    relatedPlotName plotRelationship
#> 1             <NA>             <NA>
#> 2           LGM08r          subplot
#> 3           LGM08r          subplot
#> 4           LGM08r          subplot
#> 5           LGM08r          subplot
#> 6             <NA>             <NA>
#> 7           LGM16l          subplot
#> 8           LGM16l          subplot
#> 9           LGM16l          subplot
#> 10          LGM16l          subplot
#> 11            <NA>             <NA>
#> 12          LGM38h          subplot
#> 13          LGM38h          subplot
#> 14          LGM38h          subplot
#> 15          LGM38h          subplot
#> 16            <NA>             <NA>
#> 17          LGM45h          subplot
#> 18          LGM45h          subplot
#> 19          LGM45h          subplot
#> 20            <NA>             <NA>
#> 21          LGM43h          subplot
#> 22          LGM43h          subplot
#> 23          LGM43h          subplot
#> 24          LGM43h          subplot
#> 25          LGM45h          subplot