rsMove (version 0.2.4)

poly2sample: poly2sample

Description

Converts a raster grid to points depending on how much each pixel is covered by a polygon.

Usage

poly2sample(x, y, min.cover = 1)

Arguments

x

Object of class SpatialPolygons or SpatialPolygonDataFrame.

y

A raster object or a numeric element.

min.cover

Minimum percent a pixel should be covered by a polygon for sampling (1-100). Default is 1.

Value

A SpatialPointsDataFrame with sampled pixels reporting on polygon percent coverage.

Details

poly2Sample extends on the rasterize function from the raster package making it more efficient over large areas and converting its output into point samples rather than a raster object. For each polygon in ("x"), poly2sample extracts the overlapping pixels of a reference grid. Then, for each pixel, the function estimates the percentage of it that is covered by the reference polygon. Finally, the function extracts coordinate pairs for pixels that has a percent coverage equal to or greater than min.cover. If y is a raster object, the function will use it as a reference grid. If y is a numeric element, the function will build a raster from the extent of x and a resolution equal to y.

See Also

dataQuery imgInt

Examples

Run this code
# NOT RUN {
{

 require(raster)

 # load example probability image
 file <- system.file('extdata', 'probabilities.tif', package="rsMove")
 img <- raster(file)

 # load area of interest
 file <- system.file('extdata', 'roi.shp', package="rsMove")
 roi <- shapefile(file)

 # extract samples
 samples <- poly2sample(roi, img, min.cover=50)

}
# }

Run the code above in your browser using DataLab