Generates voronoi polygons by first performing stratified sampling across boundary polygons, then by running the voronoisation with st_voronoi().

tesselate_voronoi(
  boundaries,
  with,
  boundary = "sfa",
  sample_surface = FALSE,
  sample_points = TRUE,
  nb_samples = NULL,
  min_size = 1500,
  stratify = TRUE,
  seed = 1
)

Arguments

boundaries

[sf] The boundaries to be used.

with

[sf] A set of data points to use for voronoisation.

boundary

[character] The column in boundaries that is to be used for the stratified sampling.

sample_surface

[logical] Whether to sample the surfaces in boundaries, Default to FALSE.

sample_points

[logical] Whether to sample points from with or to take all points in with. Default to TRUE.

nb_samples

[named character vector] The number of samples to draw by boundary polygons (must bear the levels of boundary as names or be a single value to be applied to each level).

min_size

[numeric] The minimum size for a polygon above which it will be merged (in km2).

stratify

[logical] Whether the discretization happens within the boundaries or whether the whole area is to be used (default to TRUE).

seed

[numeric] Passed onto set.seed(), important for reproducibility of sampling.

Value

A named list with three elements (each an sf object): * patches, the voronoi polygons generated * points, the points used for the tessellation.

Examples

data(borealis_simulated, package = "sspm")
data(sfa_boundaries, package = "sspm")
tesselate_voronoi(sfa_boundaries, with = borealis, sample_surface = TRUE,
                  boundary = "sfa", nb_samples = 10)
#> $patches
#> Simple feature collection with 40 features and 3 fields
#> Geometry type: POLYGON
#> Dimension:     XY
#> Bounding box:  xmin: -64.18658 ymin: 46.00004 xmax: -46.6269 ymax: 60.84469
#> Geodetic CRS:  WGS 84
#> # A tibble: 40 × 4
#>    sfa   patch_id patch_area                                            geometry
#>  * <chr> <fct>        [km^2]                                       <POLYGON [°]>
#>  1 4     P1            4806. ((-63.31344 59.83877, -61.99731 60.80071, -61.9924…
#>  2 4     P2            4305. ((-60.35567 59.5856, -60.72803 58.95631, -60.59911…
#>  3 4     P3            8420. ((-62.42449 58.76616, -61.8719 60.48682, -61.99731…
#>  4 4     P4            3768. ((-61.99242 60.84469, -61.99731 60.80071, -61.8719…
#>  5 4     P5            9018. ((-60.92254 57.6908, -60.93575 57.69861, -60.93575…
#>  6 4     P6            5309. ((-62.23096 58.59797, -61.7112 59.03986, -61.54144…
#>  7 4     P7            3253. ((-61.39531 59.19534, -60.76714 59.87528, -61.5414…
#>  8 4     P8            3319. ((-60.57467 59.91974, -60.76714 59.87528, -61.3953…
#>  9 4     P9            5376. ((-60.19223 57.68973, -60.17467 57.68869, -60.1741…
#> 10 5     P10          20902. ((-59.44125 55.70684, -58.57763 55.98804, -58.5229…
#> # ℹ 30 more rows
#> 
#> $points
#> Simple feature collection with 40 features and 1 field
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -62.90629 ymin: 46.61749 xmax: -47.45254 ymax: 60.64649
#> Geodetic CRS:  WGS 84
#> First 10 features:
#>    sfa                   geometry
#> 1    4 POINT (-62.90629 60.64649)
#> 2    4 POINT (-61.42425 59.71627)
#> 3    4 POINT (-59.80715 58.05237)
#> 4    4  POINT (-59.6313 57.70761)
#> 5    4 POINT (-61.00018 58.85463)
#> 6    4 POINT (-61.15296 60.43046)
#> 7    4 POINT (-60.87372 59.20766)
#> 8    4 POINT (-61.78665 59.77074)
#> 9    4 POINT (-62.35403 59.95055)
#> 10   4  POINT (-60.4377 58.94603)
#>