Learn R Programming

spi (version 1.1)

spi: Standardized Precipitation Index (SPI)

Description

The SPI function computes the SPI index (McKee et al., 1993) from a predefined time scale (1 month, 3 months, 24 months, etc.) to a period choosen by users.

Usage

spi(nargs, filename, id, fd, title, output, txlab, tylab)

Arguments

nargs
number of arguments (minimum = 3)
filename
name of datafile The datafile in ASCII format must have the following layout: lllllll{ Months 2005 2006 2007 2008 2009 2010 Jan 28.1 5.8 22.9 64.2 70.1 85.9 Feb 41.4 85.1 149.2 31.0 14
id
initial data
fd
final data
title
data title
output
output type ( 1 - graph, 2 - results matrix )
txlab
the X axis title
tylab
the Y axis title

Value

  • Returns a data matrix or a graphic with SPI values.

Details

Positive SPI values indicate greater than median precipitation and negative values indicate less than median precipitation. Drought periods are represented by relatively high negative deviations. Normally, the 'drought' part of the SPI range is arbitrary split into moderately dry (-1.0 > SPI > -1.49), severely dry (-1.5 > SPI > -1.99) and extremely dry conditions (SPI < -2.0). A drought event starts when SPI value reaches -1.0 and ends when SPI becomes positive again (McKee et al., 1993). This function use the SPI range defined by National Climatic Data Center (NCDC): ll{ exceptionally moist: SPI >= 2.0 extremely moist: 1.60

References

McKee, T.B., Doesken, N.J., Kleist, J., 1993. The relationship of drought frequency and duration to time scales. In: Preprints, Eighth Conference on Applied Climatology, January 17 e 22, Anaheim, California, pp. 179 e 184.

Examples

Run this code
##load data

data(spi_data) 

##write to file

write.table(spi_data,file="spi.txt",quote=FALSE,row.names=TRUE)	  

## Standard format with the output in the text format

spi(3,"spi.txt",1963,2010)

## A full output in graphical format

spi(7,"spi.txt",1963,2010,"Standardized Precipitation Index - Rio Grande do Norte State",1,"years","months")

Run the code above in your browser using DataLab