tableFromEpmGrid {epm} | R Documentation |
Data table from epmGrid
Description
Given one or several epmGrid objects, sf objects, rasterLayers, SpatRasters, create a table of values and associated coordinate data.
Usage
tableFromEpmGrid(..., n = NULL, minTaxCount = 1, coords = NULL, id = FALSE)
Arguments
... |
objects of class |
n |
number of cells to randomly subsample, no subsampling if |
minTaxCount |
integer; cells with at least this many taxa will be included. |
coords |
if NULL, then points are sampled as needed, otherwise, data will be extracted at these specified coordinates. |
id |
boolean, should the grid cell index (of the first item in the inputs) be returned as well? |
Details
A set of cells are identified in the input objects. If
n=NULL
, then all cells are used, otherwise cells are randomly
subsampled. Values at those cells are then returned. This table
construction can be particularly useful for subsequent statistical
analyses.
Only cells with data in all inputs are returned. If n is greater than the number of cells with data, then fewer than n cells will be returned.
The first element provided should be a epmGrid
object, and that will
be the one used as a template for the sampled grid system.
If coords
is provided, then data are extracted at those coordinates,
and no subsetting of those points is done.
Value
data.frame with input variables, as well as "x"
and
"y"
.
Author(s)
Pascal Title
Examples
tamiasEPM
tamiasEPM <- addPhylo(tamiasEPM, tamiasTree)
tamiasEPM <- addTraits(tamiasEPM, tamiasTraits)
morphoDisp <- gridMetrics(tamiasEPM, metric='disparity')
meanPat <- gridMetrics(tamiasEPM, metric='meanPatristic')
tableFromEpmGrid(tamiasEPM, morphoDisp, meanPat, n = 100,
minTaxCount = 2)
# this time request grid cell ID's, which would be useful
# for linking this table back to the grid system
tableFromEpmGrid(tamiasEPM, morphoDisp, meanPat, n = 100,
minTaxCount = 2, id = TRUE)
# from predetermined set of coordinates
pts <- sf::st_sample(tamiasEPM[[1]], size = 10)
tableFromEpmGrid(tamiasEPM, morphoDisp, meanPat, n = 100,
minTaxCount = 1, coords = pts)