Check Range Intersections with Continent Polygons
check_continents.Rd
This function checks whether the polygons representing species ranges intersect with polygons representing continents. It returns a dataframe indicating which species ranges intersect with which continents.
Value
A dataframe with species names as rows and continent names as columns. Each cell contains a 1
if the corresponding species range intersects with the continent polygon, and 0
otherwise.
Details
The function assumes that both the species range polygons and continent polygons are in the same coordinate reference system. If the range or continent polygons are invalid, they are automatically made valid using st_make_valid
. The function returns a dataframe where each row corresponds to a species, and each column corresponds to a continent. A value of 1
indicates that the species range intersects with the continent polygon, while 0
indicates no intersection.
Examples
# Generate a dataframe for species Abies cephalonica and Abies firma
test_data <- data.frame(species_name = c("Abies_cephalonica", "Abies_firma"))
# Get continent bounds
continent_bounds <- get_continent_sf()
#> Error in get_continent_sf(): Default continent GeoJSON file not found. Ensure the file is in the 'extdata' directory of the package.
# Find convex hulls for Abies cephalonica and Abies firma
test_hulls <- GeoFunPhy::get_range_convex_hulls(test_data)
#> Error in loadNamespace(x): there is no package called ‘GeoFunPhy’
# Clip convex hulls to continent bounds
clipped_polys <- clip_polygons_to_land(test_hulls, continent_bounds)
#> Error: object 'test_hulls' not found
# Check intersections with continents - Abies cephalonica is found in Europe and Abies firma is found in Asia
intersections <- check_continents(convex_hulls = clipped_polys, continent_sf = continent_bounds)
#> Error: object 'continent_bounds' not found
print(intersections)
#> Error: object 'intersections' not found