Create a dataframe that counts each patch independently for the prioritizr input
create_patch_df.Rd
This function takes all of the inputs of prioritizr and creates a dataframe precursor for prioritizr. This specific function includes the use of "patches" which have been already generated by create_patches()
. "Patches" are spatial groups of a particular feature, such as seamounts. Prioritizr will protect entire patches to meet the protection goal for that feature. The output of this function should be passed to create_boundary_matrix()
before being passed to prioritizr.
Usage
create_patch_df(
spatial_grid,
features,
patches,
costs = NULL,
locked_out = NULL,
locked_in = NULL
)
Arguments
- spatial_grid
a raster or sf template with the desired resolution and coordinate reference system generated by
spatialgridr::get_grid()
; values in areas of interest are 1, while all other values are NA- features
a raster or sf object that includes all relevant features to be used in the prioritization; each layer of the raster or each column of the sf object identifies the location of each feature
- patches
a raster or sf object generated by
create_patches()
; a single feature split into spatially distinct groups; each layer of the raster or each column of the sf object identifies the location of each patch- costs
a raster or sf object of the costs for protecting each cell in the planning grid
- locked_out
a raster or sf object for areas to be locked out (absolutely not protected) in the prioritization
- locked_in
a raster or sf object for areas to be locked in (absolutely protected) in the prioritization
Value
A data frame to be used as an input for create_boundary_matrix()
Examples
# Start with a little housekeeping to get the data from oceandatr
# Choose area of interest (Bermuda EEZ)
area <- oceandatr::get_area(area_name = "Bermuda", mregions_column = "territory1")
projection <-'+proj=laea +lon_0=-64.8108333 +lat_0=32.3571917 +datum=WGS84 +units=m +no_defs'
# Create a planning grid
planning_raster <- spatialgridr::get_grid(area, projection = projection)
# Grab all relevant data
features_raster <- oceandatr::get_features(spatial_grid = planning_raster)
#> Getting depth zones...
#> This may take seconds to minutes, depending on grid size
#> Getting seamount data...
#> Spherical geometry (s2) switched off
#> although coordinates are longitude/latitude, st_intersection assumes that they
#> are planar
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Spherical geometry (s2) switched on
#> Getting knoll data...
#> Warning: attribute variables are assumed to be spatially constant throughout all geometries
#> Getting geomorphology data...
#> Getting coral data...
#> |-- Coral data found for antipatharia coral, cold coral, octocoral
#> Getting environmental regions data... This could take several minutes
# Separate seamount data - we want to protect entire patches
seamounts_raster <- features_raster[["seamounts"]]
features_raster <- features_raster[[names(features_raster)[names(features_raster) != "seamounts"]]]
# Create a "cost" to protecting a cell - just a uniform cost for this example
cost_raster <- stats::setNames(planning_raster, "cost")
# Create patches from layer
patches_raster <- create_patches(seamounts_raster)
# Create patch dataframe
patches_raster_df <- create_patch_df(spatial_grid = planning_raster, features = features_raster,
patches = patches_raster, costs = cost_raster)
#> [1] "Processing patch 1 of 7"
#> [1] "Processing patch 2 of 7"
#> [1] "Processing patch 3 of 7"
#> [1] "Processing patch 4 of 7"
#> [1] "Processing patch 5 of 7"
#> [1] "Processing patch 6 of 7"
#> [1] "Processing patch 7 of 7"