assign_areas {CCAMLRGIS} | R Documentation |
Assign point locations to polygons
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 Subarea the given fishing locations occurred.
Usage
assign_areas(
Input,
Polys,
AreaNameFormat = "GAR_Long_Label",
Buffer = 0,
NamesIn = NULL,
NamesOut = NULL
)
Arguments
Input |
dataframe containing - at the minimum - Latitudes and Longitudes to be assigned to polygons. If |
Polys |
character vector of polygon names (e.g., Must be matching the names of the pre-loaded spatial objects (loaded via e.g., |
AreaNameFormat |
dependent on the polygons loaded. For the Secretariat's spatial objects loaded via 'load_' functions, we have the following:
Several values may be entered if several
|
Buffer |
numeric, distance in nautical miles to be added around the |
NamesIn |
character vector of length 2 specifying the column names of Latitude and Longitude fields in
the
|
NamesOut |
character, names of the resulting column names in the output dataframe,
with order matching that of |
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_MPAs
, load_EEZs
.
Examples
#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(Input=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