Hi! Neat issue. My approach in R would go like this:
Create a fishnet grid of the region with the appropriate size of cells (eg. 10 m, 100 m, 1000 m, etc.). Preferably in the sf package in R.
Extract the raster data for your first raster and average it into the fishnet grid. Repeat for the second raster you want to correlate.
Do you have some geographic boundaries that you want to use to split up the regions in your raster? Eg. If you have a rainfall dataset and a sunlight dataset for the entire US, do you want correlations for each US state? If so, you can use st_join function to merge in a vector of state names for each fishnet cell.
Last, you can use group_by() and summarize() with the cor() function to get the correlation between the two rasters.