Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions R/cc_outl.R
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,13 @@ cc_outl <- function(x,
area = terra::expanse(ref))
area <- area[!is.na(area$area), ]
area <- area[!is.na(area$country), ]

## naturalearth uses -99 for missing values?
area <- area[area$country != "-99", ]

## CN-TW (Taiwan) doesn't map to a country in the GBIF database:
## naturalearth dataset uses CN-TW for Taiwan, GBIF uses TW.
area[area$country == "CN-TW", "country"] <- "TW"

# get number of records in GBIF per country as proxy for sampling intensity
nrec <- vapply(area$country,
Expand Down
8 changes: 6 additions & 2 deletions R/cc_sea.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,9 @@ cc_sea <- function(x,
## have to make sure they are the same and in this case they already are
## -----
## point-in-polygon test
ext_dat <- terra::extract(ref, pts)
##ext_dat <- terra::extract(ref, pts)
ext_dat <- terra::relate(pts, ref, "intersects", pairs = TRUE,
na.rm = FALSE)
out <- !is.na(ext_dat[!duplicated(ext_dat[, 1]), 2])
out <- data.frame(terra::geom(pts)[, c("x", "y"), drop = FALSE], out)
colnames(out)[1:2] <- c(lon, lat)
Expand All @@ -154,7 +156,9 @@ cc_sea <- function(x,

# select relevant columns
#point in polygon test
ext_dat <- terra::extract(ref, pts)
ext_dat <- terra::relate(pts, ref, "intersects", pairs = TRUE,
na.rm = FALSE)
##ext_dat <- terra::extract(ref, pts)
out <- !is.na(ext_dat[!duplicated(ext_dat[, 1]), 2])
}

Expand Down