coast_distance {Tivy} | R Documentation |
Vectorized distance to coast
Description
Estimates the distance between a set of points (lon, lat) and a coastline defined by coordinates. Can be executed sequentially or in parallel, and also return the indices of the nearest coastal points.
Usage
coast_distance(
lon,
lat,
coastline = NULL,
return_indices = FALSE,
distance_type = "haversine",
unit = "nm",
window = 1,
parallel = FALSE,
cores = 4
)
Arguments
lon |
Numeric vector with the longitudes of the points of interest. |
lat |
Numeric vector with the latitudes of the points of interest. |
coastline |
Data frame with coastline coordinates. Must have columns named |
return_indices |
Logical. If |
distance_type |
Type of geographic distance to use: "haversine", "euclidean", "grid". |
unit |
Unit of measurement for distance: "nm" (nautical miles), "km", etc. |
window |
Search window in degrees around the point to limit calculations and improve efficiency. |
parallel |
Logical. If |
cores |
Number of cores to use for parallel processing. |
Value
If return_indices = FALSE
, returns a numeric vector with distances to the coast for each point.
If return_indices = TRUE
, returns a list with distance and index components.
Examples
## Not run:
data_hauls <- process_hauls(data_hauls = calas_bitacora)
distances <- coast_distance(
lon = data_hauls$lon_final,
lat = data_hauls$lat_final,
distance_type = "haversine",
unit = "nm",
parallel = TRUE,
cores = 2
)
## End(Not run)