join_ports_locations {dafishr}R Documentation

Label points when vessel is at port

Description

The function joins ports locations using data from ports buffers. mx_ports data is used which is provided by INEGI https://en.www.inegi.org.mx/

Usage

join_ports_locations(x, mx_ports = mx_ports, buffer_size = 0.15)

Arguments

x

a data.frame with latitude and longitude coordinates

mx_ports

is a shapefile of point data storing coordinates of ports and marina in Mexico, you can upload this using data("mx_ports")

buffer_size

a number (double) indicating the size of the buffer for the ports to implement

Details

The function adds a location column indicating if the vessel was at port or at sea.

Value

A data.frame

Examples


# With sample data

data("sample_dataset")
data("mx_ports")
vms_cleaned <- vms_clean(sample_dataset)

# It is a good idea to subsample when testing... it takes a while on the full data!

vms_subset <- dplyr::sample_n(vms_cleaned, 1000)
with_ports <- join_ports_locations(vms_subset)
with_ports_sf <- sf::st_as_sf(with_ports, coords = c("longitude", "latitude"), crs = 4326)

data("mx_shape")
library(ggplot2)
ggplot(mx_shape) +
  geom_sf(col = "gray90") +
  geom_sf(data = with_ports_sf, aes(col = location)) +
  facet_wrap(~location) +
  theme_bw()

[Package dafishr version 1.0.1 Index]