[GRASS-dev] anyone interested in helping to port an algorithm from matlab?

Dylan Beaudette dylan.beaudette at gmail.com
Wed Nov 5 20:02:24 EST 2008


On Wednesday 05 November 2008, Hamish wrote:
> Dylan Beaudette wrote:
> > The source code for the algorithm is given in Matlab source[2]. I have
> > tried unsuccessfully to port the code to R, mostly because I do not
> > completely understand several of the matlab matrix idioms used in the
> > code.
>
> what are you stuck on in particular?
>
> you can install GNU Octave to play around with Matlab-like syntax.
>
>
> dot-before-operator (e.g. ".*") for array multiplication might be a little
>
> confusing, it does like:
> >> a = [ 1 2 ]
> >> b = [ 10 20 ]
> >> a .* b
>
> ans =
>     10    40
>
> >> a * b'
>
> ans =
>     50
>
> ( ' transposes array from 1x2 to 2x1)
>
>
>
> Hamish

Hi Hamish,

Actually I was able to make some progress in R, until I got to something like 
this:

# accumulate new quadrants
# WTF ?
cc = [cc;cord]
Qc=[Qc;Qh]

if cc is matrix, and cord is a matrix, what exactly is happening?

Thanks for the tip on Ocatave, I will give that a try too. I have a sneaking 
suspicion that this algorithm is not very efficient (the fortran version), as 
it takes quite a while (well 3 minutes) to process a 400x400 grid.

I would be interesting in developing a C version, that had some additional 
functionality, and could output GRASS polygons. Also- I think that the 
algorithm has some kind of rounding or indexing errors, as I see systematic 
variation in areas of the quadrants (see attached).

Cheers,
Dylan

-- 
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341
-------------- next part --------------
A non-text attachment was scrubbed...
Name: area_not_consistant.png
Type: image/png
Size: 13364 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20081105/c71bd136/area_not_consistant-0001.png


More information about the grass-dev mailing list