ifcb_is_near_land.RdDetermines whether given positions are near land based on a buffered coastline.
ifcb_is_near_land(
latitudes,
longitudes,
distance = 100,
shape = NULL,
crs = 4326,
utm_zone = 33,
remove_small_islands = TRUE,
small_island_threshold = 2e+06
)Numeric vector of latitudes for positions.
Numeric vector of longitudes for positions.
Buffer distance in meters around the coastline. Default is 100 m.
Optional path to a shapefile containing coastline data. If provided, the function will use this shapefile instead of reading rnaturalearth 1:10m vectors. A more detailed shapefile allows for a smaller buffer distance. Detailed European coastline can be downloaded as polygons from EEA at https://www.eea.europa.eu/data-and-maps/data/eea-coastline-for-analysis-2/gis-data/eea-coastline-polygon
Coordinate reference system (CRS) to use for positions and output. Default is EPSG code 4326 (WGS84).
UTM zone for buffering the coastline. Default is 33 (between 12°E and 18°E, northern hemisphere).
Logical indicating whether to remove small islands from the coastline. Default is TRUE.
Area threshold in square meters below which islands will be considered small and removed, if remove_small_islands is set to TRUE. Default is 2 sqkm.
Logical vector indicating whether each position is near land.
This function calculates a buffered area around the coastline and checks if given positions (specified by longitudes and latitudes) are within this buffer or intersect with land.
# Define coordinates
latitudes <- c(62.500353, 58.964498, 57.638725, 56.575338)
longitudes <- c(17.845993, 20.394418, 18.284523, 16.227174)
# Call the function
near_land <- ifcb_is_near_land(latitudes, longitudes, distance = 300, crs = 4326)
# Print the result
print(near_land)
#> [1] TRUE FALSE TRUE FALSE