View source: R/rasterStackFromPolyList.R
rasterStackFromPolyList | R Documentation |
Takes a list of polygons and creates a rasterStack.
rasterStackFromPolyList( polyList, resolution = 50000, method = "midpoint", coverCutoff = 0.1, retainSmallRanges = TRUE, extent = "auto", dropEmptyRasters = TRUE )
polyList |
a list of polygons objects (sf or sp), named with taxon names. |
resolution |
vertical and horizontal size of raster cell, in units of the polygons' projection. |
method |
approach used for rasterizing. See details below. |
coverCutoff |
the percent that a species range must cover a grid cell to be considered present. |
retainSmallRanges |
boolean; should small ranged species be dropped or preserved. See details. |
extent |
if 'auto', then the maximal extent of the polygons will be used. If not auto, can be a SpatialPolygon or sf object, in which case the resulting rasterStack will be cropped and masked with respect to the polygon, or a spatial coordinates object, from which an extent object will be generated, or a numeric vector of length 4 with minLong, maxLong, minLat, maxLat. If 'interactive', then an interactive plot will appear in which the user can draw the desired polygon extent. |
dropEmptyRasters |
if |
In the rasterization process, two approaches are implemented. For method = 'midpoint'
,
a range polygon registers in a cell if the polygon overlaps with the cell midpoint.
For method = 'gridcell'
, a range polygon registers in a cell if it covers that cell by
at least coverCutoff
fraction of the cell.
If retainSmallRanges = FALSE
, then species whose ranges are so small that no
cell registers as present will be dropped. If retainSmallRanges = TRUE
, then the
cells that the small polygon is found in will be considered as present, even if it's a
small percent of the cell. retainSmallRanges
only applies to method = 'gridcell'
.
If dropEmptyRasters = TRUE
and retainSmallRanges = TRUE
, then the species
that will be dropped are those that are outside of the requested extent (which in that
case would be specified explicitly).
In interactive mode for defining the extent, the user can draw a bounding polygon on a map. The drawn polygon will then be printed to the console so that the user can hard-code that bounding polygon in future calls to this function.
Any SpatialPolygon or SpatialPoints objects are converted to objects of class sf
.
This function uses the fasterize
package for conversion from polygon to raster.
In interactive mode, the basemap is from www.naturalearthdata.com.
an object of class RasterStack
where all rasters contain values of
either NA or 1.
Pascal Title
library(raster) library(sf) # example dataset: a list of 24 chipmunk distributions as polygons head(tamiasPolyList) rangeStack <- rasterStackFromPolyList(tamiasPolyList, resolution = 50000) rangeStack
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.