Как и у вас, у меня было много НС, но я мог получить все, кроме одного, если бы я буферизовал экстент bounds
:
# remotes::install_github("adamhsparks/GSODRdata", build_vignettes = TRUE)
library(GSODRdata)
library(GSODR)
library(dplyr)
library(sf)
library(raster)
climate <- raster("CHELSAcruts_prec_8_2015_V.1.0.tif")
# https://stackoverflow.com/a/49159943/3362993
climate <- reclassify(climate, cbind(-Inf, 0, NA), right=FALSE)
NL <- get_GSOD(years = 2010, country = "Netherlands", max_missing = 5)
bounds <- GSODRdata::CHELSA[,c("STNID", "CHELSA_prec_8_1979-2013")] %>%
left_join(NL, by = "STNID") %>%
dplyr::filter(!is.na(LON)) %>%
distinct(STNID, `CHELSA_prec_8_1979-2013`, .keep_all = TRUE) %>%
dplyr::filter(LON > -33) %>% # fix misclassified county codes
st_as_sf(coords = c("LON", "LAT"), crs = 4326)
climate_nl <- raster::crop(climate, as_Spatial(st_buffer(bounds, 0.1)))
res <- extract(climate_nl, as_Spatial(bounds))
plot(climate_nl)
plot(bounds, add = TRUE, color = "black")
plot(bounds[which(is.na(res)),]$geometry, add = TRUE, color = "red", pch = 19)
legend("topleft", legend = c("NA vals"), pch = 19)