<div dir="ltr"><div><div>Hi Javier,<br><br></div>Thanks. I need to test whether the mahalanobis function you provided is faster than the one I used (which Glynn wrote, based on the numpy function I believe); I think I can use both together with the function to run it in parallel, so it would be a matter of selecting the fastest one (or the one using less memory, if there is such a difference). <br><br></div><div>I am not sure if I understand the parallel part, but it seems the data is 'sliced' in subsets to compute the distance. If so, that should indeed solve the problem with large files? Anyway, I'll try how it works for me. <br><br>For now I do the partitioning of the data in subsets in GRASS (create a dummy layer, split that in tiles using r.tile, set the region to match tile 1, import the input layers in python (which will be restricted to the region defined by tile 1), run the function and import the result back in GRASS, set region to match tile 2, impor the data... etc). Much slower I guess (not really tested yet), but should be able to handle any data size that GRASS can handle.<br><br>To create a grass plugin to compute the mahalanobis distance based on that code would be trivial I think, I can give that a try if you want. As for the rest of the code, I would be interested to help, but my grass/python programming are very limited, so hopefully there are others interested as well.<br><br></div><div>Cheers,<br><br></div><div>Paulo<br></div><div><div><br><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Feb 16, 2015 at 11:35 AM, Javier Martínez-López <span dir="ltr"><<a href="mailto:javi.martinez.lopez@gmail.com" target="_blank">javi.martinez.lopez@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Paulo,<br>
<br>
to use it with python just copy the mahalanobis function definitions,<br>
import all necessary libraries and use it as in line 597 (the<br>
covariance matrix and the mean are computed just before this line). I<br>
am sorry that the code is not documented yet. I am not sure if this<br>
will solve the large raster layers problem but you can try it. As you<br>
can see in the script, I did not write the parallel mahalanobis<br>
functions (Sturla Molden in CC did it) and it works perfectly for me,<br>
so I agree that it would be great to implement it also in GRASS (maybe<br>
as an add on?). However, I am not so experienced with that. The<br>
ehab.py script also does a lot data preprocessing to allow batch runs<br>
using heterogeneous data sources and finally performs some patch<br>
analysis and metrics out of the resulting similarity maps using the<br>
ndimage library (scipy). Any help on how to implement it in GRASS<br>
would be more than welcome! Cheers, Javier<br>
<br>
On Sun, Feb 15, 2015 at 10:21 PM, Paulo van Breugel<br>
<div class="HOEnZb"><div class="h5"><<a href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a>> wrote:<br>
> Hi Javier,<br>
><br>
> This looks really useful, thanks! My python skills are very limited, so I<br>
> will have to look at it better to see what I can understand. But to start,<br>
> the parallel function, does that also solve the handling of potentially very<br>
> large raster layers?<br>
><br>
> Btw, this does look like a very useful set of functions, any plan to develop<br>
> this into a GRASS addon or function?<br>
><br>
> Paulo<br>
><br>
><br>
> On Sun, Feb 15, 2015 at 9:22 PM, Javier Martínez-López<br>
> <<a href="mailto:javi.martinez.lopez@gmail.com">javi.martinez.lopez@gmail.com</a>> wrote:<br>
>><br>
>> Hi Paulo,<br>
>><br>
>> you can see an implementation of the mahalanobis distance computed in<br>
>> parallel (using all computer processors) for a single image here:<br>
>><br>
>> <a href="https://github.com/javimarlop/eHabpy/blob/master/ehab.py" target="_blank">https://github.com/javimarlop/eHabpy/blob/master/ehab.py</a><br>
>><br>
>> see lines 32-86 and 597. I hope it helps! Cheers, Javier<br>
>><br>
>> On Sat, Feb 14, 2015 at 7:29 PM, Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>><br>
>> wrote:<br>
>> ><br>
>> > On Sat, Feb 14, 2015 at 11:47 AM, Paulo van Breugel<br>
>> > <<a href="mailto:p.vanbreugel@gmail.com">p.vanbreugel@gmail.com</a>><br>
>> > wrote:<br>
>> >><br>
>> >><br>
>> >> For a quick solution, what about using r.tile to split the input data<br>
>> >> in<br>
>> >> tiles and compute the mahalanobis distance per tile.<br>
>> ><br>
>> ><br>
>> > See PyGRASS GridModule class which will do tiling (and a lot of other<br>
>> > things) for you.<br>
>> ><br>
>> ><br>
>> > <a href="http://grass.osgeo.org/grass70/manuals/libpython/pygrass.modules.grid.html" target="_blank">http://grass.osgeo.org/grass70/manuals/libpython/pygrass.modules.grid.html</a><br>
>> ><br>
>> > _______________________________________________<br>
>> > grass-dev mailing list<br>
>> > <a href="mailto:grass-dev@lists.osgeo.org">grass-dev@lists.osgeo.org</a><br>
>> > <a href="http://lists.osgeo.org/mailman/listinfo/grass-dev" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-dev</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div></div></div></div>