addPlotLocations: Adds/replaces plot location information

View source: R/addPlotLocations.R

addPlotLocationsR Documentation

Adds/replaces plot location information

Description

Adds/replaces static plot location information (spatial coordinates, elevation, place names, ...) to plot elements of a VegX object from a data table where rows are plots.

Usage

addPlotLocations(
  target,
  x,
  mapping,
  proj4string = NULL,
  reset.places = FALSE,
  toWGS84 = FALSE,
  methods = list(),
  missing.values = c(NA, ""),
  missing.coords = c(NA, 0, ""),
  missing.elevation = c(NA, 0, ""),
  verbose = TRUE
)

Arguments

target

The initial object of class VegX to be modified

x

A data frame where each row corresponds to one plot. 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).

  • x, y - Spatial coordinates of the plot (optional).

  • elevation - Elevation of the plot (optional).

  • authorLocation - A string describing the location of the plot as made by the author (optional).

  • locationNarrative - (optional).

  • placeName, placeType - A string of a place name and place type (e.g. province, county, ...) (optional).

Note that placeName and placeType will add new places to the list of places.

proj4string

A string with projection attributes (see proj4string of package sp) to be used when 'x' and 'y' are supplied. This parameter is needed if toWGS84 = TRUE.

reset.places

Whether the 'places' vector should be reset before adding new place names.

toWGS84

A boolean flag to indicate that coordinates should be transformed to "+proj=longlat +datum=WGS84".

methods

A named list with measurement methods for plot horizontal/vertical location measurements (each being an object of class VegXMethodDefinition). Alternatively, methods can be specified using strings if predefined methods exist (see predefinedMeasurementMethod). For example, methods = c(xy = method1, elevation = method2). Measurement method for coordinates is not required, but that for 'elevation' is.

missing.values

A character vector of values that should be considered as missing data (but see the following).

missing.coords

A character vector of values that should be considered as missing coordinates (introduced to allow separate treatment).

missing.elevation

A character vector of values that should be considered as missing elevation (introduced to allow separate treatment).

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 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. elevation, x, y, ...) 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(), addPlotObservations(), addSiteCharacteristics(), addSiteObservations(), addStratumObservations(), addSurfaceCoverObservations(), addTaxonBySiteData()

Examples

data(mokihinui)

# Define location mapping
mapping = list(plotName = "Plot", x = "Longitude", y = "Latitude")

# Create new Veg-X document with plot locations
x = addPlotLocations(newVegX(), moki_loc, mapping,
                     proj4string = "+proj=longlat +datum=WGS84")

# Summary of the new Veg-X document
showElementTable(x, "plot")

# Add 'elevation' from another table (moki_site). This implies considering subplots.
mapping = list(plotName = "Plot", subPlotName = "Subplot", elevation = "Altitude")
x = addPlotLocations(x, moki_site, mapping, 
                     methods = list(elevation = "Elevation/m"))
                     
# Summary of the updated Veg-X document
showElementTable(x, "plot")


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