concave_area | R Documentation |
concave_area helps in creating concave polygons based on occurrences, buffering polygons, masking raster layers, and writing results if needed.
concave_area(data, longitude, latitude, length_threshold = 5,
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_concave")
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. |
length_threshold |
(numeric) distance in km to define when a segment length stops being considered for further detalization. Higher values result in simpler shapes. Default = 5. |
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 concave 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 concave polygons
cv_area <- concave_area(data = occurrences, longitude = "longitude",
latitude = "latitude")
sp::plot(cv_area)
points(occurrences[, 2:3])
# producing concave polygons with buffers
cv_area1 <- concave_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50)
sp::plot(cv_area1)
points(occurrences[, 2:3])
# producing concave polygons splitted considering clusters
cv_area2 <- concave_area(data = occurrences, longitude = "longitude",
latitude = "latitude", split = TRUE,
cluster_method = "k-means", n_kmeans = 2,
buffer_distance = 5)
sp::plot(cv_area2)
points(occurrences[, 2:3])
# producing concave polygons, masking layers
vars <- raster::stack(list.files(system.file("extdata", package = "ellipsenm"),
pattern = "bio", full.names = TRUE))
cv_area3 <- concave_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50,
raster_layers = vars, mask = TRUE)
raster::plot(cv_area3$masked_variables[[1]])
sp::plot(cv_area3$calibration_area, add = TRUE)
points(occurrences[, 2:3])
# producing concave polygons, masking layers, and saving results
cv_area4 <- concave_area(data = occurrences, longitude = "longitude",
latitude = "latitude", buffer_distance = 50,
raster_layers = vars, mask = TRUE, save = TRUE,
name = "concave_area")
# check directory
dir()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.