Description Usage Arguments Details Value See Also Examples
View source: R/raster2sample.R
Converts a raster grid to points.
1 |
x |
Object of class SpatialPolygons or SpatialPolygonDataFrame. |
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.
A SpatialPointsDataFrame with sampled pixels reporting on pixel compactness.
1 2 3 4 5 6 7 8 9 10 11 12 | {
require(raster)
# load example image
r <- raster(system.file("extdata", "ndvi.tif", package="fieldRS")[1])
r[r < 5000] <- NA
# extract samples
samples <- raster2sample(r)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.