convex_area | R Documentation |
convex_area helps in creating convex polygons based on occurrences, buffering polygons, masking raster layers, and writing results if needed.
convex_area(data, longitude, latitude, split = FALSE,
cluster_method = "hierarchical", split_distance = NULL,
n_kmeans = NULL, buffer_distance = NULL,
raster_layers = NULL, clip = FALSE, mask = FALSE,
save = FALSE, name = "calib_area_convex")
data |
data.frame of occurrence records containing at least longitude and latitude columns. |
longitude |
(character) name of the column with longitude data. |
latitude |
(character) name of the column with latitude data. |
split |
(logical) if TRUE, a distance (for hierarchical clustering) or a number (for K-means clustering) is used to separate distinct chunks of data Recommended when the species of interest has a disjunct distribution. Default = FALSE. |
cluster_method |
(character) name of the method to be used for clustering
the occurrences. Options are "hierarchical" and "k-means"; default =
"hierarchical". Note that this parameter is ignored when |
split_distance |
(numeric) distance in km that will be considered as the
limit of connectivity among polygons created with clusters of occurrences.
This parameter is used when |
n_kmeans |
(numeric) if |
buffer_distance |
(numeric) distance in km to be used to create a buffer for the convex hull. Default = NULL. |
raster_layers |
optional RasterStack to be used in restricting the resulting SpatialPolygon and in preparing variables for further processing. Default = NULL. |
clip |
(logical) whether or not to clip polygons considering boundaries
of layers in |
mask |
(logical) whether or not to mask the |
save |
(logical) whether or not to write the results in the working directory. Default = FALSE. |
name |
(character) name of a folder to be written with the results if
|
If raster layers are masked, a lits containing a SpatialPolygonDataFrame and a RasterStack of the masked layers.
If raster layers are not masked, a SpatialPolygonDataFrame.
If save
= TRUE, results are written in a folder named as in name
.
# reading data
occurrences <- read.csv(system.file("extdata", "occurrences.csv",
package = "ellipsenm"))
# producing simple convex polygons
cx_area <- convex_area(data = occurrences, longitude = "longitude",
latitude = "latitude")
sp::plot(cx_area)
points(occurrences[, 2:3])
# producing convex polygons with buffers
cx_area1 <- convex_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50)
sp::plot(cx_area1)
points(occurrences[, 2:3])
# producing convex polygons splitted considering clusters
cx_area2 <- convex_area(data = occurrences, longitude = "longitude",
latitude = "latitude", split = TRUE,
cluster_method = "k-means", n_kmeans = 2,
buffer_distance = 5)
sp::plot(cx_area2)
points(occurrences[, 2:3])
# producing convex polygons, masking layers
vars <- raster::stack(list.files(system.file("extdata", package = "ellipsenm"),
pattern = "bio", full.names = TRUE))
cx_area3 <- convex_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50,
raster_layers = vars, mask = TRUE)
raster::plot(cx_area3$masked_variables[[1]])
sp::plot(cx_area3$calibration_area, add = TRUE)
points(occurrences[, 2:3])
# producing convex polygons, masking layers, and saving results
cx_area4 <- convex_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50,
raster_layers = vars, mask = TRUE, save = TRUE,
name = "convex_area")
# check directory
dir()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.