Build a concave-hull prediction region from survey positions
Source:R/prediction-grid.R
make_survey_prediction_region.RdCreates an sf polygon describing the spatial footprint of a set of sampling
positions, using a concave hull (concaveman::concaveman()). This is used to
restrict a prediction grid to the area a survey actually covers, rather than
the full model domain.
Usage
make_survey_prediction_region(
data,
crs,
xy_cols = c("X", "Y"),
coord_multiplier = 1000,
concavity = 5,
buffer = 1
)Arguments
- data
A data frame with coordinate columns (see
xy_cols) in the same units as the model (typically km).- crs
Coordinate reference system of the projected coordinates.
- xy_cols
Character vector of length two naming the coordinate columns. Default
c("X", "Y").- coord_multiplier
Numeric factor to convert
xy_colsto the CRS units (e.g.1000to convert km to m). Default1000.- concavity
Numeric. Concavity parameter passed to
concaveman::concaveman(). Larger values give looser (more convex) hulls. Default5.- buffer
Numeric. Buffer (in CRS units) applied to the hull to avoid clipping the outermost stations. Default
1.
Examples
# \donttest{
data(sebastes)
eggan <- subset(sebastes, cruiseseries == "EggaN")
region <- make_survey_prediction_region(eggan, crs = 32633, concavity = 5)
if (requireNamespace("ggOceanMaps", quietly = TRUE)) {
library(ggOceanMaps) # qmap() needs ggOceanMaps attached
qmap(region, fill = I(NA))
}
#> Loading required package: ggplot2
#> ggOceanMaps: Setting data download folder to a temporary folder
#> /tmp/Rtmpecbtz7. This means that any downloaded map data need to be
#> downloaded again when you restart R. To avoid this problem, change the
#> default path to a permanent folder on your computer. Add following
#> lines to your .Rprofile file: {.ggOceanMapsenv <- new.env();
#> .ggOceanMapsenv$datapath <- 'YourCustomPath'}. You can use
#> usethis::edit_r_profile() to edit the file. '~/ggOceanMapsLargeData'
#> would make it in a writable folder on most operating systems.
# }