addSurfaceCoverObservations: Add surface cover observation records

View source: R/addSurfaceCoverObservations.R

addSurfaceCoverObservationsR Documentation

Add surface cover observation records

Description

Adds surface cover observation records to a VegX object from a data frame where rows are cover observations.

Usage

addSurfaceCoverObservations(
  target,
  x,
  mapping,
  coverMethod,
  surfaceTypeDefinition,
  date.format = "%Y-%m-%d",
  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 surface cover observation (e.g. bare rock percent cover). 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).

  • obsStartDate - Plot observation start date (required; see date.format).

  • surfaceName - The string of the name of a surface type (see surfaceTypeDefinition; required).

  • coverMeasurement - Surface cover values (required).

coverMethod

A method definition for surface cover measurements (an object of class VegXMethodDefinition). Alternatively, the method can be specified using a string if a predefined method exists (see predefinedMeasurementMethod).

surfaceTypeDefinition

An object of class VegXSurfaceTypeDefinition indicating the definition of surface types.

date.format

A character string specifying the input format of dates (see as.Date).

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.

Details

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

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

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

  • Missing values of coverMeasurement are simply not added to the Veg-X document.

Value

The modified object of class VegX.

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

See Also

Other add functions: addAggregateOrganismObservations(), addCommunityObservations(), addIndividualOrganismObservations(), addPlotGeometries(), addPlotLocations(), addPlotObservations(), addSiteCharacteristics(), addSiteObservations(), addStratumObservations(), addTaxonBySiteData()

Examples

# Load source data
data(mtfyffe)

# Examine surface cover data
head(mtfyffe_groundcover)

# Define mapping
mapping = list(plotName = "Plot", obsStartDate = "PlotObsStartDate",
               surfaceName = "PlotGroundCover", coverMeasurement = "Value")


# Get cover measurement method from predefined list
coverMethod = predefinedMeasurementMethod("Surface cover/%")

# Define surface types from the data
unique(mtfyffe_groundcover$PlotGroundCover)
surfaceTypes = defineSurfaceTypes(name = "Default surface types",
                  description = "Five surface categories",
                  surfaceNames = c("Vegetation", "Moss", "Litter", "Exposed Soil", "Rock"))

# Create new Veg-X document with surface cover observations
x = addSurfaceCoverObservations(newVegX(), mtfyffe_groundcover, mapping,
                                coverMethod, surfaceTypes)

# Examine results
head(showElementTable(x, "surfaceCoverObservation"))


# Another example with different surface types
data(takitimu)
head(taki_groundcover)

unique(taki_groundcover$PlotGroundCover)
surfaceTypes = defineSurfaceTypes(name = "Default surface types",
                  description = "Five surface categories",
                  surfaceNames = c("Vegetation", "Soil", "Erosion Pavement", "Litter","Rock"))

x = addSurfaceCoverObservations(newVegX(), taki_groundcover, mapping,
                                coverMethod, surfaceTypes)

head(showElementTable(x, "surfaceCoverObservation"))


miquelcaceres/VegX documentation built on Sept. 18, 2022, 7:04 p.m.