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. 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. Sometimes, two or more polygons can cover the same pixel. When this happens,
the function will assign this pixel to each of the overlapping polygons and thus replicate this sample. When
we want to analyze each polygon individually this can be useful. However, if e.g. the polygons are all of same
class and we want to avoid replicated samples, we can set preserve.id to FALSE. When doing so, the
function will identify all the unique pixels covered polygons and for, the duplicated it will sum the percent
cover values. Points with percent values below min.cover will be omitted from the output.