I have two spatial dataframes of points, one is nest locations of a rare bird and its associated breeding data for each year (i.e. how many young were produced at each nest) and the other is tropical cyclone data (a series of points following the cyclones path and its associated intensity such as wind velocity, central pressure, etc).
I want to perform a spatial join so I can look at the potential impact of tropical cyclones on the breeding rates of this bird.
First I buffered the nest locations by 50km then ran the st_join function to join the tropical cyclone points that intersect with the 50km nest buffer. See here -
nests_tc_data <- st_join(nests_50km_buffer, tc_dat, join = st_intersects, left = TRUE)
This works great but Im having a post-processing problem as the join captures all the tropical cyclone data from all years going back through time rather than just the years where I have the breeding data to compare it to.
Is there a way to perform the join based on the spatial intersection of the two layers, but also the YEAR variable of the two events so Im only left with breeding and cyclone data that match in both time and space??
Thank you, Chris.
nests_tc_data <- st_join(nests_50km_buffer, tc_dat, join = st_intersects, left = TRUE)
This works but doesnt match the YEAR variable in the two datasets, just their spatial location (i.e. whether they intersect or not).