r.regression.pl carries out linear regression on two or more rasters, according to the formula y = a + b*x. Unlike r.regression.line, however, the regression here does not compute one solution, in which all of the x values are on one raster and all of the y values are on another. Rather, it calculates a solution for each pixel, where the x values and y values are contained on any number of raster pairs in a time series.
This allows for the analysis of the spatial variation of any number of raster partnerships in which one surface may be considered dependent upon another, where each change with time. Some examples would be:
In order to carry out the regression, two or more sets of ordered x,y pairs are required. In this case one ordered pair is represented by two raster images, one for the independent x variable, and one for the dependent y variable. As there need to be at least two ordered pairs, this means a minimum of four raster images. The raster maps must be named carefully in order that the script can associate the image pairs.
There are two distinct methods of organising the raster maps.
This is the faster and preferred method, and is instigated when the -d flag is not set. Maps representing the x and y values will be expected to have names ending in the suffices set in the xsuffix and ysuffix flags, respectively. Associated x,y pairs are recognised by their common prefix (the entire part of the name prior to the suffix).
This method is triggered by setting the -d flag. The directory (folder) named in the inputdirectory parameter will be searched for GDAL-recognisable image files. The script will expect the files to each comprise two bands, the first of which will be imported as the x raster, and the second as the y raster.
Method 1 (Raster maps within the current Mapset) carries out each of the three calculations for gradient, intercept and coefficient of determination in one go, as the data all resides within Grass.
Method 2 (External files in a directory) brings in the two bands from each external file on-by-one, adding each component to aggregates stored in temporary rasters. As a result, many more calculations need to be performed, and the process is much slower. An advantage may be that there is no real limit to the number of files being processed as less memory is used. It should only really be used when Method 1 refuses to work due to memory issues.
The following example assumes you have rainfall data in maps with suffix rain and soil moisture data in maps with suffix soil:
GRASS 6.4.1 (Example):~/ > g.list rast ---------------------------------------------- raster files available in mapset <PERMANENT>: january.rain january.soil july.rain july.soil ---------------------------------------------- GRASS 6.4.1 (Example):~/ > r.regression.pl outpre=rainsoil xsuffix=.rain ysuffix=.soil x is '.rain' and y is '.soil' The following prefices correspond to eligible raster pairs: january, july Creating gradient raster... 100% Creating intercept raster... 100% Creating Coefficient of Determination raster... 100% GRASS 6.4.1 (Example):~/ > g.mlist type=rast pattern='rainsoil.*' rainsoil.R2 rainsoil.gradient rainsoil.intercept
The following example assumes you have a sub-directory in your current directory called Rainfall, which contains two 2-band tif files: january.tif and july.tif:
GRASS 6.4.1 (Example):~/ > r.regression.pl -d inputdirectory=Rainfall outpre=rainsoil Reading Rainfall/january.tif... Projection of input dataset and current location appear to match 100% r.in.gdal complete. Raster map <temp.1> created. 100% r.in.gdal complete. Raster map <temp.2> created. 100% Reading Rainfall/july.tif... Projection of input dataset and current location appear to match 100% r.in.gdal complete. Raster map <temp.1> created. 100% r.in.gdal complete. Raster map <temp.2> created. 100% The raster maps rain.gradient, rain.intercept and rain.R2 have been created GRASS 6.4.1 (Example):~/ > g.mlist type=rast pattern='rainsoil.*' rainsoil.R2 rainsoil.gradient rainsoil.intercept
Main index - raster index - Full index
© 2003-2012 GRASS Development Team