View source: R/rasterToPoints.R
rasterToPoints | R Documentation |
Raster to point conversion. Cells with NA are not converted. A function can be used to select a subset of the raster cells (by their values).
rasterToPoints(x, fun=NULL, spatial=FALSE, ...)
x |
A Raster* object |
fun |
Function to select a subset of raster values |
spatial |
Logical. If |
... |
Additional arguments. Currently only |
fun
should be a simple function returning a logical value.
E.g.: fun=function(x){x==1}
or fun=function(x){x>3}
A matrix with three columns: x, y, and v (value), or a SpatialPointsDataFrame object
r <- raster(nrow=18, ncol=36)
values(r) <- runif(ncell(r)) * 10
r[r>8] <- NA
p <- rasterToPoints(r)
p <- rasterToPoints(r, fun=function(x){x>6})
#plot(r)
#points(p)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.