0

I have rainfall data (corresponding to latitude, longitude, and amount of rainfall at that latitude and longitude.) I plotted this data using a 2D matrix, with matrix(i,j) corresponding to the i'th and j'th (sorted) latitudes and longitudes in my dataset. I want to find out the direction of maximum variance of my rainfall data. How do I do this? Here's an illustrative example:

Suppose my matrix is as follows: (mapped onto a world grid i.e. the smaller latitudes are at the bottom and the smaller longitudes and towards the left of the matrix)

1 2 3 4
2 3 3 4
3 2 5 4
4 2 3 7

Row i and column j correspond to a grid of longitudes and latitudes defined by, say, 34, 35, 37, 43 and -43, -24, 0, 12 respectively (i.e. the bottom-most and left-most point corresponds to the longitude and latitude 34,-43) while the actual value in the matrix corresponds to the amount of rainfall at that position. In this toy example, the direction of highest variance is obviously along the top-left-to-bottom-right diagonal. Therefore, I essentially have a three dimensional dataset where each element is [longitude, latitude, rainfall]. How would I find out the direction of maximum variance for the actual rainfall values themselves? I tried using PCA but that takes into account the variation in the latitudes and longitudes themselves.

As a side question, would this question become easier if the latitudes and longitudes are regularly separated? I think it's a different problem altogether but would like to hear others' perspective on this.

requiemman
  • 61
  • 6

1 Answers1

0

I'm guessing you want the variance of rainfall across the geographic area sampled, rather than the variance within your rainfall dataset (which would just be sqrt(mean([(rf-avg_rf) ** 2 for rf in rainfall_vals]))). It sounds like the main issue is interpolating your rainfall data into regular latitude/longitude steps, sort of like a topographical map would do after sampling the elevation at certain points. If you look up "rainfall data interpolation" you'll find some more nuanced tips- like whether or not to use inverse distance weighing, etc.- but here's the gist.

Once you've interpolated to your liking you can apply that simple method I mentioned at the start on your new, filled-out array of rainfall data.

  • Suppose I've already interpolated my data. Your method gives me the value of the variance - but how do I get the direction of the maximum variance? – requiemman Jul 11 '23 at 23:53