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 NamesIn is not provided, the columns in the Input must be in the following order: Latitude, Longitude, Variable 1, Variable 2, ... Variable x..

Polys

character vector of polygon 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 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

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

NamesIn

character vector of length 2 specifying the column names of Latitude and Longitude fields in the Input. Latitudes name must be given first, e.g.:

NamesIn=c('MyLatitudes','MyLongitudes').

NamesOut

character, names of the resulting column names 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_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




[Package CCAMLRGIS version 4.1.1 Index]