I would like to calculate SPEI using the R package developed by the authors. There seems to me to be two major reasons why I can't use the R package (I'm currently trying to figure out SPEI in Matlab). I'm computing SPEI for a city over 17 years at 30-meter resolution. Currently, I have all of my precipitation, potential evapotranspiration, and water balance data for the time series. Since I want the 3-month SPEI I also summed the water balances in three month chunks (April+May+June, May+June+July, etc.)

First, my data has a lot of NaNs, and the R package doesn't accept any NaNs. I can't delete my NaNs because the location of each data point in the matrix represents its location in space (lat/long). Is there any way around this? I need to know specifically which lat/long pixel an SPEI value corresponds to.

Second, my data is relatively high resolution. I have lots of pixels for each month in my 17-year study, however, it looks to me like the R package only accepts one data point per month, since each new row represents the following month. I was thinking of putting all my data points for each month into a vector along each row, particularly since the R package computes SPEI for each column individually, and I would like SPEI on a pixel-per-pixel basis. However, each row would be over 3 million points long, and I think I read somewhere that this is far beyond what the R package is able to handle.

Is there any way around these two issues so that I can use the R package? I'm having a lot of difficulty figuring out how to calculate SPEI in Matlab (trying to figure out probability-weighted moments). Thanks for any feedback.

https://cran.r-project.org/web/packages/SPEI/SPEI.pdf

https://cran.r-project.org/web/packages/SPEI/SPEI.pdf

More Dion Kucera's questions See All
Similar questions and discussions