Issue in finding nearest values in dataframes for different variables (based on location and conditions)
I have a combined_vars_df
and surge_df
, wave_df
, and waterlevel_df
for 235 counties on the “Atlantic” and “GulfOfMexico” coasts. Their few lines of data information are given below. I am using dates of combined_vars_df
and selecting the same dates in surge_df
, wave_df
and waterlevel_df
, and calculating distances (using haversine
package) from longitude_precip
and latitude_precip
to latitudes
and longitudes
of surge, wave and waterlevel dfs and select the nearest locations of surge, wave and waterlevel and select their corresponding percentiles and other corresponding columns to add them in combined_vars_df. I am using the following conditions for calculating distances and finding the nearest location and its corresponding percentiles: