I have a large table of swell period associated with a lat, long, and date/time. Lat, long, and date are separate columns. I have a smaller table of exact locations, lat and longs in seperate column, in which I want to extract swell period per date/time stamp. I am stumped on how to do this. I have provided samples of my code and tables below. My attempt seems to only pull out 6 of the 20 locations. I am confident there is matching lat and longs.
x <- as.vector(round(c(-121.110423, -120.562848, -120.057825, -119.717691, -119.439510, -119.041160, -118.586216,
-118.507400, -118.087338, -117.662998, -117.437052, -117.335509, -118.160157, -119.059945,
-119.943535, -120.515873, -119.070552, -118.295248, -119.471023, -120.584913), 2))
y <- as.vector(round(c(34.560459, 34.253113,34.348268, 34.147373, 34.256965, 33.989257, 33.913609, 33.699766, 33.576926,
33.272809, 32.922927, 32.535688, 32.606003, 32.500511, 32.644805, 33.138259, 33.135506, 33.102819,
33.696946, 33.703024), 2))
ta_loc <- as.data.frame(cbind(x, y))
Ta_data <- as.data.frame(rasterToPoints(final_ras_ta)) %>%
pivot_longer(!c(x,y), names_to = "date", values_to = "period") %>%
mutate(date = gsub("X", "", date),
date = as.numeric(date),
date = as_datetime(date),
x = round(x, 2),
y = round(y , 2)) %>%
filter(x %in% ta_loc$x,
y %in% ta_loc$y )
a <- Ta_data %>%
st_as_sf(. , coords = c("x", "y"), crs = 4326)
b <- ta_loc %>%
st_as_sf(. , coords = c("x", "y"), crs = 4326)
loc <- a %>%
group_by(date) %>%
filter(geometry == b$geometry)