SPI Program

Note: A new version of the program has been tested and released as of 12/7/2018. All of the necessary files are included in the download zip file.


Program and Documentation


The SPI Generator application serves to generate SPI (Standard Precipitation Index) data and illustrate how to interact with the SPI DLL (Dynamically Linked Library). The application reads in precipitation data and supports different time scales and data types (weekly, monthly). It outputs SPI data and, optionally, frequency and drought period data. In addition to executing as a Windows GUI (Graphical User Interface) it can also execute from the command line.

Standard Precipitation Index Summary

The SPI is calculated from the historical precipitation record at a weather station, where precipitation accumulation over a period of time is compared to that same period of time throughout the historical record at that location. The SPI for any precipitation accumulation value represents the probability that the location would have received at least the observed amount of precipitation over the time period. The SPI calculated in this program is based on representing the historical precipitation record with a gamma distribution. Positive SPI values represent wet conditions; the higher the SPI, the more unusually wet a period of time is. Negative SPI values represent dry conditions; the lower the SPI, the more unusually dry a period of time is.

The primary strength of the SPI is that its data can be compared between different climate regions. Since the SPI compares precipitation amounts at a weather station to that particular station’s own precipitation history, SPI data from different stations usually can be directly compared, because the SPI communicates how anomalous a precipitation amount is, not just the raw departure from normal precipitation. For regions with highly seasonal precipitation (particularly where very little to no precipitation usually falls for several months), users should be cautious when directly comparing data from these areas. The SPI generator can also be used to compute standardized indices for other variables (commonly, streamflow). Some caution should be exercised when analyzing this output, since the gamma distribution may not be the best distribution to use to model non-precipitation variables.

Technical Details

The application requires Microsoft’s .NET 4.0 framework and can be compiled as a 32- or 64-bit executable. The application consists of two files: a vb.net 4.0 application and a c#.net 4.0 DLL.

  • SPIGenerator.exe – the Windows console application.
  • StandardPrecipitationIndex.dll – the SPI DLL.

Running the application as a Windows application or command line produces the same program flow:

  1. Retrieve and verify input parameters
  2. Parse input file
  3. Aggregate data
  4. Calculate SPI
  5. Write results to file

Note: More extensive documentation is available in the zip file.