Skip to contents

Categorize polygon by Province/State if applicable

Usage

assign_prov_state(
  strata_map,
  min_overlap = 0.75,
  plot = FALSE,
  keep_spatial = TRUE
)

Arguments

strata_map

sf data frame. Strata polygons to be categorized.

min_overlap

Numeric. The minimum proportion of overlap between a stratum polygon and a Province or State. Below this will raise warnings.

plot

Logical. Whether to plot how polygons were assigned to Provinces or States

keep_spatial

Logical. Whether the output should be a spatial data frame or not.

Value

(Spatial) data frame with strata assigned to Province/State

Examples


# Demonstration of why we can't divide BCR by Provinces and States!
map <- load_map("bcr")
assign_prov_state(map, plot = TRUE)
#> Warning: 28 strata are assigned to a province or state based on less than the minimum specified overlap

#> Simple feature collection with 223 features and 7 fields
#> Geometry type: GEOMETRY
#> Dimension:     XY
#> Bounding box:  xmin: -4748423 ymin: -1638890 xmax: 2988370 ymax: 4517253
#> Projected CRS: North_America_Albers_Equal_Area_Conic
#> # A tibble: 223 × 8
#>    strata_name prov_…¹ country count…² provi…³                      geom  p_area
#>  * <chr>       <chr>   <chr>   <chr>   <chr>              <GEOMETRY [m]>   <dbl>
#>  1 BCR11       SK      United… US      Minnes… POLYGON ((-34912.42 1040… 8.17e-2
#>  2 BCR12       ON      United… US      Minnes… POLYGON ((227176.7 69461… 1.42e-1
#>  3 BCR22       IL      United… US      Minnes… MULTIPOLYGON (((-26502.4… 1.91e-2
#>  4 BCR23       WI      United… US      Minnes… MULTIPOLYGON (((44306.22… 2.14e-1
#>  5 BCR12       ON      Canada  CA      Ontario MULTIPOLYGON (((922663.3… 3.34e-1
#>  6 BCR13       ON      Canada  CA      Ontario MULTIPOLYGON (((1290956 … 4.12e-1
#>  7 BCR22       IL      Canada  CA      Ontario POLYGON ((999527.4 33729… 3.66e-5
#>  8 BCR23       WI      Canada  CA      Ontario POLYGON ((1036571 408074… 6.82e-5
#>  9 BCR7        QC      Canada  CA      Ontario MULTIPOLYGON (((426946.4… 1.53e-1
#> 10 BCR8        QC      Canada  CA      Ontario MULTIPOLYGON (((526422.6… 2.95e-1
#> # … with 213 more rows, 1 more variable: note <chr>, and abbreviated variable
#> #   names ¹​prov_state, ²​country_code, ³​province_state

# Use custom stratification, using sf map object
# e.g. with WBPHS stratum boundaries 2019
# available: https://ecos.fws.gov/ServCat/Reference/Profile/142628

if (FALSE) {
map <- sf::read_sf("../WBPHS_Stratum_Boundaries_2019") %>%
  rename(strata_name = STRAT) # expects this column
s <- assign_prov_state(map, plot = TRUE)
# Some don't divide nicely, we could try a different min_overlap

s <- assign_prov_state(map, min_overlap = 0.6, plot = TRUE)
}