lxy.gridanv.add: Add ancillary variable(s) to a LoCoH-xy object from a raster

Description Usage Arguments Value Note

Description

Add ancillary variable(s) to a LoCoH-xy object from a raster

Usage

1
2
3
lxy.gridanv.add(lxy, band = NULL, dtfn = NULL, fn = NULL,
  anv.name = NULL, anv.desc = NULL, date.match = c("closest",
  "before")[1])

Arguments

lxy

LoCoH-xy object

band

Numeric vector of which band(s) to read. If omitted, all bands will be read.

dtfn

A two-column data frame containing a date and filename

fn

Filename of a raster

anv.name

The name(s) of the ancillary variable(s) that will be added to the LoCoH-xy object (one per band)

anv.desc

A character vector of short descriptions of each ancillary variable

date.match

How to match dates when dtfn is used: 'closest' or 'before'. See note.

Value

A LoCoH-xy object

Note

This function will create new ancillary variables and fill it with the value of the pixel at each point. The image should be in the same coordinate system as the points (the script however does not check this). Any points that fall beyond the edges of the image will be given 'NA' values. If an ancillary variable with the same name already exists, it will be overwritten.

The raster image specified by fn must be in a format supported by the readGDAL function in the rgdal package (run gdalDrivers for a list of supported formats). Multi-band formats are supported. If the image has multiple bands, you can specify which band(s) to read using the optional argument band. A separate ancillary variable will be created for each band. You can provide name(s) for the ancillary variable(s) with the anv.name parameter.

You can also pass a time-series of images, and the function will use the image from the closest date for each point. To do this, pass a two-column data frame as the argument dtfn. The first column of dtfn must be a date (in one of the POSIXt date-time classes), and the second column must be a valid raster filename associated with that date. If each image is a time composite, (e.g., two-week NDVI), the date should either be the mid-point or the beginning date. Two options for time matching are available through the argument date.match. When date.match='closest', the image whose date is closest in time (before or after) will be used. When date.match='before', it will pick the first image that comes before the location.


tlocoh documentation built on May 2, 2019, 5:27 p.m.