Learn R Programming

fieldRS (version 0.2.3)

raster2sample: raster2sample

Description

Converts a raster grid to points.

Usage

raster2sample(x)

Arguments

x

Object of class SpatialPolygons or SpatialPolygonDataFrame.

Value

A SpatialPointsDataFrame with sampled pixels reporting on pixel compactness.

Details

poly2Sample extends on the rasterToPoints function from the raster package. For each non-NA pixel in x, the function will use 3x3 moving window and report on the frequency of non-NA pixels. This can be useful to identify "pure" samples within a clump of pixels (i.e. high frequency) as well as mixed pixels along their borders (i.e. low frequency). The output is a SpatialPointsDataFrame reporting on:

  • x - x coordinate.

  • y - y coordinate.

  • cover - Non-NA value frequency.

  • id - Corresponding raster value in x.

See Also

poly2sample ccLabel

Examples

Run this code
# NOT RUN {
{

 require(raster)

 # load example image
 r <- raster(system.file("extdata", "ndvi.tif", package="fieldRS")[1])
 r[r < 5000] <- NA
 
 # extract samples
 samples <- raster2sample(r)

}
# }

Run the code above in your browser using DataLab