[GRASS-user] Grass Script- Implementing a Quadratic Mahalanobis Distance

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Fri Oct 15 07:45:30 EDT 2010


(
Pedro, I kindly ask you to keep the discussion on the list - it's very 
interesting (to me at least) and of wider interest (I guess) as a small 
challenge for grass. I am sure others can help here.

Also, accept my apologies for re-structuring the mail to make it easy to 
follow for other readers.
)

Pedro wrote:

> > > I need to implement a Quadratic Mahaloanobis Distance by using GRASS.
> > > This is based on medium vector and covariance matrix.

> > > 1- As anyone implemented anything similar?
> > > 2- If not, Is there any GRASS script that accesses medium vector and
> > > Covariance matrix in its processing?

Nikos:

> > Not sure at all but my guess is that it's a (simple) job for grass if you
> > know the formula. I am not familiar with the term "medium" vector. But 
> > there is "r.covar" to get the covariance (or correlation) matrix based on
> > raster maps.

Pedro:

> Medium vector is a vector/array in which each element is the average of
> that class in each image
> [average in image1; average in image2, ...]

> The problem of implemeting this in a script is that it required matrix
> calculation. I mean, for each pixel in a class, I will have to multiplicate
> byt the covariance matriz and this vector.
 
I don't have a quick answer on how to do it within grass using r.mapcalc. But 
I am convinced that using grass + R is a solution. Also, is the following 
matlab (open source?) code of any use?

<http://www.hackchina.com/en/r/129852/mahalanobis.m__html>

I've read on the net efforts trying to link R and matlab. If the latter is 
practically doable, then you can even avoid writing the code (again). So, I 
imagine something like:

 1. import data in grass and prepare/process etc.
 2. load data of interest in R
 3. calculate the (qudratic) mahalanobis distances of interest (within R with 
R code/ with matlab code ?)
 4. export results (or even maps) in grass back again

Cheers, Nikos


More information about the grass-user mailing list