<div dir="ltr"><div>Hi Markus and others,<br><br>I would do a backport or r61812 but I'm not sure if it works correctly. It seems to work and I got the same results as with the old version but I remember that you (Markus) had some doubts at one point. Now I actually see that you said you will backport it, so if you have your plan disregard this message.<br><br></div>I also wanted to use the things bellow to write a test but I don't know how.<br><div><br></div><div>Vaclav<br></div><div><br><a href="http://trac.osgeo.org/grass/changeset/61812">http://trac.osgeo.org/grass/changeset/61812</a><br><br><br>---------- Forwarded message ----------<br>From: Sandra MacFadyen <<a href="mailto:sandramf@live.co.za">sandramf@live.co.za</a>><br>Date: Mon, Sep 29, 2014 at 9:24 PM<br>Subject: RE: [GRASS-user] Solved: execGRASS("r.diversity") Done. No rasters created (Large rasters)<br>To: Vaclav Petras <<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>><br>Cc: Markus Neteler <<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>>, GRASS user list <<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>>, Duccio Rocchini <<a href="mailto:ducciorocchini@gmail.com">ducciorocchini@gmail.com</a>>, Luca Delucchi <<a href="mailto:lucadeluge@gmail.com">lucadeluge@gmail.com</a>><br><br><br>Dear Vaclav,<br><br> <br><br>I did a quick manual test to see if the results were correct for a few 5x5 windows and yes, everything appears 100%:<br><br> <br><br># Example data from one 5x5 window<br><br>test1 = c(572,617,661,638,616,<br><br>          662,617,593,638,616,<br><br>          662,639,572,661,616,<br><br>          662,662,639,662,616,<br><br>          594,572,594,639,593)<br><br> <br><br># Calculate info needed for diversity indices<br><br>freq1 = as.data.frame(table(test1)) # Calculate frequency table<br><br>S = length(unique(test1)) # Total number of species (S)<br><br>N = length(test1) # Total number of individuals (N)<br><br>ln.S = log(S) #Natural log of species (ln S)<br><br>ln.N = log(N) # Natural log of individuals (ln N)<br><br>Pi = freq1$Freq/N # Proportion of individuals that belong to each species<br><br>Pi2 = (Pi ^ 2)<br><br>ln.pi = log(Pi)<br><br>pi.ln.pi = Pi * ln.pi<br><br>pi.ln.pi2 = (ln.pi^2)*Pi<br><br> <br><br># Calculate different diversity indices<br><br>(M = (S-1)/ln.N) # Margalef's index (M)<br><br>(i.Di = 1/sum(Pi2)) # Simpson's index [Inverse] (i.Di)<br><br>(i.Dc = 1 - (sum(Pi2))) # Simpson's index [Complement] (i.Dc) * This one calculated with r.diversity<br><br>(H = sum(pi.ln.pi)*-1) # Shannon-Wiener index (H')<br><br>(J = H/ln.S) # Pielou's index (J)<br><br> <br><br>Thanks again<br><br> <br><br>Cheers<br><br>Sandra<br><br> <br><br>From: Vaclav Petras [mailto:<a href="mailto:wenzeslaus@gmail.com">wenzeslaus@gmail.com</a>]<br>Sent: 18 September 2014 02:46 AM<br>To: Sandra MacFadyen<br>Cc: Markus Neteler; GRASS user list; Duccio Rocchini; Luca Delucchi<br>Subject: Re: [GRASS-user] Solved: execGRASS("r.diversity") Done. No rasters created (Large rasters)<br><br> <br><br> <br><br> <br><br>On Wed, Sep 17, 2014 at 7:40 PM, Sandra MacFadyen <<a href="mailto:sandramf@live.co.za">sandramf@live.co.za</a>> wrote:<br><br>Dear Markus,<br><br>Excellent! Thanks to everyone for their help.<br>I tested r.diversity in the new revision (61840) on a raster with 12933032 cells and it took under 3 minutes to complete r.li.simpson, r.li.shannon, r.li.pielou and r.li.renyi outputs.<br>Amazing :)<br><br>> execGRASS("r.diversity",flags="overwrite", parameters=list(input="flow", prefix="flow_div", alpha=0.5, size=3))<br>> r.li.simpson complete. Raster map <flow_div_simpson_size_3.0> created.<br>> r.li.shannon complete. Raster map <flow_div_shannon_size_3.0> created.<br>> r.li.pielou complete. Raster map <flow_div_pielou_size_3.0> created.<br>> r.li.renyi complete. Raster map <flow_div_renyi_size_3.0_alpha_0.5><br>> created.<br>> Done.<br><br>Thanks again and keep well.<br><br>Good to hear that. Can you say if the results are correct? I computed difference of one map before and after and it was OK. But it would be great to have more tests. Let's start with: does the result make sense?<br><br> <br><br>Vaclav<br> <br><br>Cheers<br>Sandra<br><br>-----Original Message-----<br>From: <a href="mailto:neteler.osgeo@gmail.com">neteler.osgeo@gmail.com</a> [mailto:<a href="mailto:neteler.osgeo@gmail.com">neteler.osgeo@gmail.com</a>] On Behalf Of Markus Neteler<br>Sent: 06 September 2014 05:15 AM<br>To: Sandra MacFadyen<br>Cc: GRASS user list; Duccio Rocchini; Luca Delucchi<br>Subject: Re: [GRASS-user] execGRASS("r.diversity") Done. No rasters created (Large rasters)<br><br>Dear Sandra,<br><br>On Fri, Jun 20, 2014 at 7:49 AM, Markus Neteler <<a href="mailto:neteler@osgeo.org">neteler@osgeo.org</a>> wrote:<br>> On Sat, Jun 14, 2014 at 9:21 AM, Sandra MacFadyen <<a href="mailto:sandramf@live.co.za">sandramf@live.co.za</a>> wrote:<br>>> I am using r.diversity (GRASS GIS 7.0.0svn build 60785 win32) through<br>>> R (R version 3.0.2 win32) on Windows 7 64bit.<br>...<br>>> However, when running the same code on a larger image (cells=6746328)<br>>> from my own location, although it reports Done, no rasters are<br>>> created. If I subset the image<br>>> (cells=1632830) and run it again its works (see # sub2Kruger # code and results below).<br>>> So I'm guessing it is a memory issue?<br>...<br>> ... it consumes a lot of memory... will check on a bigger machine,<br>> perhaps a memory leak.<br><br>The assumption turned out to be right and I think we got it today!<br><br>Vaclav Petras checked it and discovered an "unfortunate" memory allocation which he fixed in r.li.* in revision <a href="http://trac.osgeo.org/grass/changeset/61812">http://trac.osgeo.org/grass/changeset/61812</a> ("<a href="http://r.li">r.li</a>: fix memory handling (memory leak in avl_to_array function))".<br><br>Now <a href="http://r.li">r.li</a> has become very fast, on my laptop:<br><br>GRASS 7.1.svn (nc_spm_08_grass7):~ >  g.region -p rast=lsat5_1987_10 res=10 -a ...<br>rows:       1355<br>cols:       1503<br>cells:      2036565<br><br>GRASS 7.1.svn (nc_spm_08_grass7):~ > time -p r.li.simpson --o input=lsat5_1987_10@landsat conf=conf_diversity_5.0<br>output=lsat5_1987_div__simpson_size_5.0<br>r.li.simpson complete. Raster map <lsat5_1987_div__simpson_size_5.0><br>created.<br>--> 29.32 seconds<br><br>or with a simulated higher resolution:<br><br>GRASS 7.1.svn (nc_spm_08_grass7):~ >  g.region -p rast=lsat5_1987_10<br>res=5 -aprojection: 99 (Lambert Conformal Conic) ...<br>rows:       2708<br>cols:       3005<br>cells:      8137540<br><br>GRASS 7.1.svn (nc_spm_08_grass7):~ > time -p r.li.simpson --o input=lsat5_1987_10@landsat conf=conf_diversity_5.0<br>output=lsat5_1987_div__simpson_size_5.0<br>r.li.simpson complete. Raster map <lsat5_1987_div__simpson_size_5.0><br>created.<br>--> 227.37 seconds (used to be > 2 hours)<br><br>So, to grab this improvement for Windows, grab the version from here:<br><a href="http://wingrass.fsv.cvut.cz/grass71/">http://wingrass.fsv.cvut.cz/grass71/</a><br><br>(or via OSGeo4W installer). Be sure that the revision is at least<br>r61812 which is indicated in the file name.<br><br>Please let us know if all works to avoid that the change has any negative impact.<br>Tests here did not show any changes in the output except for the speed improvement and solved memory leak.<br><br>Subsequently also r.diversity should behave now.<br><br>I'll backport it to GRASS 7.0 release branch after some testing.<br><br>Markus<br><br>_______________________________________________<br>grass-user mailing list<br><a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a><div><div class="gmail_quote"><div link="blue" vlink="purple" lang="EN-ZA"><div><div><div class="h5"><div><div><p class="MsoNormal"><u></u> <u></u></p></div></div></div></div></div></div></div><br></div></div></div>