Generate Location Buffers and Assign CAPAD Protected Area Names
Source:R/locationName_buffer_CAPAD.R
locationName_buffer_CAPAD.RdThis function buffers deployment locations, identifies overlapping or nearby protected areas from the Collaborative Australian Protected Areas Database (CAPAD) database, and assigns dominant protected area names to each buffer. It handles deployments across multiple UTM zones and incorporates a nearest-neighbor approach for locations outside CAPAD boundaries.
Arguments
- dep
A dataframe containing deployment data, including columns for
latitude,longitude, anddeploymentID. It may also includeUTMzone,X, andYcoordinates. If these are missing, they will be generated using theWildObsR::UTM_coord_generatorfunction.- buffer_size
Numeric value representing the size of the buffer (in meters) around each deployment location. Defaults to 5,000 m (5 km).
Value
An updated dataframe containing the original deployment data and an additional column,
CAPADlocationNameBuffer, which specifies the buffer ID and the corresponding protected area name.
Stops if any deploymentID appears more than once.
Details
This function performs the following steps:
Validates and generates UTM coordinates for the deployment locations, if necessary.
Buffers deployment points within their respective UTM zones, merging results across zones.
Dissolves overlapping buffers and assigns unique IDs to each disaggregated polygon.
Extracts the dominant protected area name for each buffer using the CAPAD 2022 terrestrial layer bundled with the package (
capad).For buffers that do not intersect with any protected area, determines the nearest protected area based on centroid distance.
Assigns the final protected area name and buffer ID to the original deployment dataframe.
Examples
# two cameras of the Woomargama project shipped with WildObsR
dp <- example_datapackages("NSW_Woomargama_wombats_Linley_2021-22_WildObsID_0010")[[1]]
dep <- frictionless::read_resource(dp, "deployments")
dep <- dep[c(1, 40), c("deploymentID", "latitude", "longitude")]
# group cameras whose 1 km buffers overlap, named by the main protected area
buffered_dep <- locationName_buffer_CAPAD(dep, buffer_size = 1000)
buffered_dep[, c("deploymentID", "CAPADlocationNameBuffer")]
#> deploymentID CAPADlocationNameBuffer
#> 1 10_WildObsID_0010_2021_a_Cam1 Landscape_1_Woomargama_NP
#> 2 18_WildObsID_0010_2021_a_Cam1 Landscape_2_Woomargama_NP