I have made s SpatialPolygonDataFrame (bs_land) with a shape file of the land and cropped it for the Artic Ocean. I also have a dataset with species records (data) and I want to check if all of them are marine. When I plot the data, I can see that some records are on land. I wanted to extract now the records that are only in the ocean but I can't seem to find a way.
Can somebody help?
Many thanks in advance!
library(ggOceanMaps)
library(sf)
land <- read_sf("ne_10m_land.shp")
lims <- c(-8, 65, 68, 82)
projection <- "EPSG:3995"
bs_land <- clip_shapefile(land, lims)
bs_land <- sp::spTransform(bs_land, CRSobj = sp::CRS(projection))
rgeos::gIsValid(bs_land) # Has to return TRUE, if not use rgeos::gBuffer
bs_land <- rgeos::gBuffer(bs_land, byid = TRUE, width = 0)
sp::plot(bs_land)
basemap(limits = 60, glaciers = TRUE, bathymetry = TRUE) +
annotation_spatial(bs_land) +
geom_spatial_point(data = data, aes(x = decimalLongitude, y = decimalLatitude), color = "darkorange")
I can see on the map that some points are on land. How can I extract the points that are only in the ocean so not on the shape file?