Learn R Programming

CCAMLRGIS (version 3.0.4)

assign_areas: Assign Areas

Description

Given a set of polygons and a set of point locations (given in decimal degrees), finds in which polygon those locations fall. Finds, for example, in which ASD the given fishing locations occurred.

Usage

assign_areas(
  Input,
  Polys,
  AreaNameFormat = "GAR_Long_Label",
  Buffer = 0,
  NamesOut = NULL
)

Arguments

Input

dataframe containing - at the minimum - Latitudes and Longitudes to be assigned to polygons.

The columns in the Input must be in the following order: Latitude, Longitude, Variable 1, Variable 2, ... Variable x..

Polys

character vector of spatial objects names (e.g., Polys=c('ASDs','RBs')).

Must be matching the names of the pre-loaded spatial objects (loaded via e.g., ASDs=load_ASDs())

AreaNameFormat

dependent on the polygons loaded. For the Secretariat's spatial objects loaded via 'load_' functions, we have the following:

'GAR_Name' e.g., 'Subarea 88.2'

'GAR_Short_Label' e.g., '882'

'GAR_Long_Label' (default) e.g., '88.2'

Several values may be entered if desired (if several Polys are used), e.g. c('GAR_Short_Label','GAR_Name'), in which case AreaNameFormat must be given in the same order as Polys.

Buffer

distance in nautical miles to be added around the Polys of interest. Can be specified for each of the spatial objects named in Polys (e.g., Buffer=c(2,5)). Useful to determine whether locations are within Buffer nautical miles of a polygon.

NamesOut

names of the resulting area columns in the output dataframe, with order matching that of Polys (e.g., NamesOut=c('Recapture_ASD','Recapture_RB')). If not provided will be set as equal to Polys.

Value

dataframe with the same structure as the Input, with additional columns corresponding to the Polys used and named after NamesOut.

See Also

load_ASDs, load_SSRUs, load_RBs, load_SSMUs, load_MAs, load_RefAreas, load_MPAs, load_EEZs.

Examples

Run this code
# NOT RUN {

#Generate a dataframe
MyData=data.frame(Lat=runif(100,min=-65,max=-50),
                  Lon=runif(100,min=20,max=40))

#Assign ASDs and SSRUs to these locations (first load ASDs and SSRUs)
ASDs=load_ASDs()
SSRUs=load_SSRUs()

MyData=assign_areas(MyData,Polys=c('ASDs','SSRUs'),NamesOut=c('MyASDs','MySSRUs'))

#View(MyData)
table(MyData$MyASDs) #count of locations per ASD
table(MyData$MySSRUs) #count of locations per SSRU

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab