Inverse distance weighting for panel data set

Hi All!
Could anyone help me?

I have monthly .csv data from 2007-2017 with monthly average temperature for 100 stations located in some counties. I have a total of 300 counties. I want to do IDW to calculate the monthly average temperature for all the 300 counties. I want to code this IDW using the three closest stations from each county centroid. And also for the 3 closest up to 50 km.

I have no idea how to do this with my panel data with 11 years, 12 months each and 300 counties.
Thank you!!
Cheers!

See the FAQ: How to do a minimal reproducible example reprex for beginners for framing questions to attract more specific answers.

Given a data frame with the variables

station,county,long,lat,t1,t2,...t120 #t1 = 2007-01-01, etc.

the location variables can be converted to a simple feature point object, using the {sf} package. If counties are in the US, the {tidycensus} package will fetch counties as simple feature polygon objects. sf can derive the centroid of each county. Depending on preferences, you can then calculate either simple euclidian distances or geodetic distances.

Thank you very much!

1 Like

Come back with a new question if you have implementation difficulties.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.