Filters FORCIS data by a spatial bounding box.
Arguments
- data
a
data.frame
. One obtained byread_*_data()
functions.- bbox
an object of class
bbox
(packagesf
) or a vector of fournumeric
values defining a square bounding box. Values must follow this order: minimum longitude (xmin
), minimum latitude (ymin
), maximum longitude (xmax
), and maximum latitude (ymax
). Important: if a vector of numeric values is provided, coordinates must be defined in the system WGS 84 (epsg=4326
).
Examples
# Attach the package ----
library("forcis")
# Import example dataset ----
file_name <- system.file(file.path("extdata", "FORCIS_net_sample.csv"),
package = "forcis")
net_data <- read.table(file_name, dec = ".", sep = ";")
# Add 'data_type' column ----
net_data$"data_type" <- "Net"
# Dimensions of the data.frame ----
dim(net_data)
#> [1] 2451 77
# Filter by oceans ----
net_data_sub <- filter_by_bbox(net_data, bbox = c(45, -61, 82, -24))
# Dimensions of the data.frame ----
dim(net_data_sub)
#> [1] 320 77