getSampleValues: Extract raster values at sample points

Description Usage Arguments Value See Also Examples

View source: R/getSampleValues.R

Description

Given a Raster* object and a SpatialPointsDataFrame object, the functions returns a SpatialPointsDataFrame objects with the values of the raster at sample points.

Usage

1
getSampleValues(x, s, keepCols = FALSE, filename = "", ...)

Arguments

x

A Raster* object

s

Location of the sample points. Object of class SpatialPointsDataFrame generated with getSample

keepCols

Should the columns of s be retained? Default is FALSE

filename

Character. Output filename including path to directory. File will be automatically saved as an ESRI Shapefile and any extension in filename will be overwritten

...

Additional arguments passed to writeOGR

Value

SpatialPointsDataFrame object

See Also

extract

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# Load raster package
library(raster)

# Open and stack ALS metrics
elev_p95 <- raster(system.file("extdata/examples/ALS_metrics_p95.tif",package="foster"))
cover <- raster(system.file("extdata/examples/ALS_metrics_cov_mean.tif",package="foster"))
Y_vars <- stack(elev_p95,cover)
names(Y_vars) <- c("p95","cover")

# sample_points is a SpatialPointsDataFrame calculated and saved from getSample
# Load it into memory
load(system.file("extdata/examples/sample_points.RData",package="foster"))

getSampleValues(Y_vars, sample_points)

mqueinnec/foster documentation built on March 28, 2021, 4:27 p.m.