Checks that a species input handed between LandWeb pipeline stages is not empty, and returns it unchanged so the check can wrap the reference inline.

landweb_require_species(x, name)

Arguments

x

the input to check: a data.frame (e.g. sppEquiv, cohortData), a SpatRaster (e.g. speciesLayers), or a named list holding one of those as element name (e.g. the result of SpaDES.targets::sim_objects()).

name

character; the object's name, used to find it in a list and in the error message.

Value

x, unchanged.

Details

The upstream Biomass_* modules and LandR treat a study area with no tree species as valid: an empty species table, NULL species layers or an empty cohortData make them skip their work and finish without error. For LandWeb every study area is forested, so an empty species input can only mean a broken species mapping, and a run would otherwise "succeed" with no vegetation dynamics. This turns that into an error at the stage boundary.

Examples

landweb_require_species(data.frame(species = "Pice_mar"), "sppEquiv")
#>    species
#> 1 Pice_mar