The following functions are used internally to the main functions.

Build trip

Called by create_fishing_trip.
This function serve to calculate and to format trip information and to assemble the output table.

build_trip(data, index, xstart, xpos, index2, ports_buffer, ports)
  • data: AIS positions
  • index: header specifying the iteration
  • xstart: indicates the id of the first point of the trip
  • xpos: indicates the offset to be imposed on xstart
  • index2: header specifying the id of the fishing trip to be assembled
  • ports_buffer: 0.001° buffer of the ports layer
  • ports: ports layer


Check cluster

Called by classification_wrapper.
This function analyzes the speed profile of the points contained within a spatial cluster, and indicates if the proportion of the point indicated by the target speed is above a specified threshold

check_cluster(data, gear, threshold, low_speed)
  • data: AIS positions with a column indexing the points belonging to spatial clusters and one indicating the cluster identified by the k-means for each point
  • gear: target fishing gear. Accepted values are PTM, PS
  • threshold: threshold to filter target speed data
  • low_speed: indicates which is the cluster of the k-means referring to the target speed.


Classify

Called by classification_wrapper.
This function identifies the size of each track.

classify(data)
  • data: output of classifify_speed


Classify speed

Called by classification_wrapper.
Classified speed applies the k-means algorithm on fishing speed data, then it uses time information to identify transmission gaps (or data with time lag > parameter specified by user). Classification results are homogenized with a lookahead (3 points) and finally points are clustered into tracks based on k-means result and time information.

classify_speed(data, gear, xcentroids, pars)
  • data: AIS positions
  • gear: target gear. Accepted values are OTB1, OTB2, PTM, TBB, PS.
  • xcentroids: object containing the centroid list inherited from the input .csv file.
  • pars: object storing the parameter file.


Core function

Called by classification_wrapper.
This function controls most of the functions called by classification_wrapper, and apply them in the right sequential order to one fishing trip at time. It search for spatial clusters of points by appliying a dbscan algorithm and then it classify the fishing data basing on the speed by applying a kmeans algorithm. Information on the spatial cluster and on the speed classification are evaluated within a set of rules designed to identify a range of fishing gears.

core_function(trip_data, pars)
  • trip_data: list of AIS positions divided by trip
  • pars: object storing the parameter file.


Data partitioning for model

This function is not called by any of the functions listed in the processing workflow.
This function serve to format the data required to train the Random Forest algorithm.

data_partition(data)
  • data: groundthuth information for vessels gear.


Find in harbour

Called by create_fishing_trip.
This function is used to individuate if there are points (x,y) that fall within the polygon of harbours, and, eventually, it indicates which are these points.

find_inport(data, ports)
  • data: AIS positions
  • ports: ports layer


Find the closest harbour

Called by create_fishing_trip.
This function was used to assign the harbor to fishing session the start or finish without a “in harbor” position. The departure or the arrival harbor was assigned considering the closest harbor respect to the first or last position of the session:

closest_port(longitude , latitude, ports)
  • longitude-latitude: are the coordinates of the first or last point of the fishing session
  • ports: is the shapefile with harbors locations


Find the closest harbour recovery

Called by create_fishing_trip.
This function is used to assign the beginning and ending ports of fishing tripsduring the recovery step of the create_fishing_trip function. This function individuate if there are harbours closest then 50 km with respect to the first or last position of the trip. If there are harbours, the function selects the closest five, then it checks if the reference_port is included in the closest five. If yes, it assign this harbour, if no, it assign the closest harbour:

closest_port_recovery(longitude , latitude, ports, reference_port)
  • longitude-latitude: are the coordinates of the first or last point of the fishing trip
  • ports: ports layer
  • reference_port: is the harbour at the other extremity of the fishing trip. Example: if longitude and latitude indicates the first point of the trip, reference_port will be the port of arrival.


Find the overlapping harbour

Called by create_fishing_trip.
This function is used to assign the beginning and ending ports of fishing trips, by the means of a spatial intersection between coordinates and the ports buffer layer. If the intersection is successful, it return the name of the identified harbour:

get_port(longitude , latitude, ports_buffer, ports)
  • longitude-latitude: are the coordinates of the first or last point of the fishing trip
  • ports_buffer: 1km buffer of the ports layer
  • ports: ports layer


Identify transmission gaps

This function is not called by any of the functions listed in the processing workflow.
This function recycles the data gaps from the function “core_function” and retrieves tracks corresponding to gaps in the AIS signal.

identify_trasmission_gaps(data, coord_sys)
  • data: results from “classification wrapper” function, consisting in raw AIS data labelled with the k-means results
  • coord_sys: coordinates system (e.g.: WGS 84)


Import parameters

This function is not called by any of the functions listed in the processing workflow.
The import_parameters allows to load the required parameters of several internal functions.

import_parameters(parameters, centroids)
  • parameters: an external csv file with the following parameters:
  • centroids: an external csv file containing the set of centroids values to test using the kmeans method in the classification alghorithm


Inspect coastal ban zone

Called by create_fishing_trip.
This function is used to individuate if the last point of a fishing trip (n) and the first point of the subsequent fishing trip (n+1), lies within the coastal ban zone. It returns the number of points individuated:

incoastal_ban_zone(longitude_start , latitude_start , longitude_end , latitude_end, coastline)
  • longitude-latitude_start: are the coordinates of the first point of the fishing trip n+1
  • longitude-latitude_end: are the coordinates of the last point of the fishing trip n
  • coastal_ban_zone: coastal ban zone layer


Make tracks lite

Called by classification_wrapper.
This function assigns unique ids to subsequent points if they fall within the same cluster inherited from k-means, thus creating groups of homogeneous points, corresponding to different phases of the activity (mainly steaming and fishing). Then it removes the first and the last steaming tracks.

make_segment_lite(data, gear)
  • data: AIS positions with a column indicating the cluster identified by the k-means for each point.
  • gear: target fishing gear. Accepted values are OTB1, OTB2, TBB, PTM, PS


Search cluster

Called by classification_wrapper.
This function applies the dbscan algorithm to identify spatial clusters in the input data.

search_cluster(data, pars, gear)
  • data: AIS positions
  • pars: object storing the parameter file. Different parameters are provided for different fishing gears.
  • gear: target fishing gear. Accepted values are OTB1, OTB2, PTM, TBB.