<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Helvetica;
panose-1:2 11 6 4 2 2 2 2 2 4;}
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"New serif";
panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.yiv6359193583msonormal0, li.yiv6359193583msonormal0, div.yiv6359193583msonormal0
{mso-style-name:yiv6359193583msonormal0;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.yiv6359193583msonormal, li.yiv6359193583msonormal, div.yiv6359193583msonormal
{mso-style-name:yiv6359193583msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
p.yiv6359193583msochpdefault, li.yiv6359193583msochpdefault, div.yiv6359193583msochpdefault
{mso-style-name:yiv6359193583msochpdefault;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
span.yiv6359193583msohyperlink
{mso-style-name:yiv6359193583msohyperlink;}
span.yiv6359193583msohyperlinkfollowed
{mso-style-name:yiv6359193583msohyperlinkfollowed;}
span.yiv6359193583emailstyle18
{mso-style-name:yiv6359193583emailstyle18;}
p.yiv6359193583msonormal1, li.yiv6359193583msonormal1, div.yiv6359193583msonormal1
{mso-style-name:yiv6359193583msonormal1;
margin:0cm;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"New serif",serif;}
span.yiv6359193583msohyperlink1
{mso-style-name:yiv6359193583msohyperlink1;
color:blue;
text-decoration:underline;}
span.yiv6359193583msohyperlinkfollowed1
{mso-style-name:yiv6359193583msohyperlinkfollowed1;
color:purple;
text-decoration:underline;}
p.yiv6359193583msonormal01, li.yiv6359193583msonormal01, div.yiv6359193583msonormal01
{mso-style-name:yiv6359193583msonormal01;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:12.0pt;
font-family:"New serif",serif;}
span.yiv6359193583emailstyle181
{mso-style-name:yiv6359193583emailstyle181;
font-family:"Arial",sans-serif;
color:#1F497D;}
p.yiv6359193583msochpdefault1, li.yiv6359193583msochpdefault1, div.yiv6359193583msochpdefault1
{mso-style-name:yiv6359193583msochpdefault1;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:10.0pt;
font-family:"Times New Roman",serif;}
span.EmailStyle30
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NO-BOK" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Hi Bernado,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">It depends what you consider general. Even if I work with landscape ecology myself, I would assume landscape metrics or
functional connectivity to be rather “special” than “general” statistics.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Putting a lot of functionality into one module can be very useful for some cases, but can come with a number of drawbacks
as well.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">A general Unix concept is to do one thing and do it well, and rather write modular programs that work together than very
complex single tools…<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Cheers<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">Stefan<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D;mso-fareast-language:EN-US">1:
<a href="https://en.wikipedia.org/wiki/Unix_philosophy"><span style="color:#1F497D;text-decoration:none">https://en.wikipedia.org/wiki/Unix_philosophy</span></a><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Bernardo Santos <bernardo_brandaum@yahoo.com.br>
<br>
<b>Sent:</b> torsdag 12. april 2018 16.57<br>
<b>To:</b> Helmut Kudrnovsky <hellik@web.de>; grass-user@lists.osgeo.org; Stefan Blumentrath <Stefan.Blumentrath@nina.no><br>
<b>Subject:</b> Re: RE: [GRASS-user] zonal statistics/metrics - beyond simple statistics<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">Hi Stephan,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">Some minutes before you sent me this e-mails, I'd just found out about v.db.select -r. It worked and made the process much faster. Thanks for that anyway.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">In my case, the polygons do not overlap. Indeed, many things could be done with r.univar, r.stats or a combination of them and their output info. However, my aim was to think about a way
of generalizing it, so that we would be able to use many other functions from the raster maps using the same architecture for calculating the zonal statistics/metrics.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">For example, I am still not sure how I would use a combination of r.univar/r.stats and some kind of input raster map to produce, say, zonal info of number of habitat patches, structural or
functional connectivity, isolation, or other more complex metrics used in landscape ecology.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">That's way I was building something like that, so that we can just write an alternative function using any raster input map that returns the value of one of such metrics, and then use it
to calculate them over sets of zones.<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">Best,<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">B<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-family:"Helvetica",sans-serif">PS: thanks for sharing your code! This v.rast.bufferstats seems very useful, and I can think of some very interesting applications of that. I helped a friend to write something similar but
using ArcPy as a ArcMap toolbox, and we applied it to some interesting cases in the delimitation of Protected Areas' buffer zones (but still did not published it). But doing that with a free and open source tool would be much more interesting! <o:p></o:p></span></p>
</div>
<div id="yahoo_quoted_4488561620">
<div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Em quarta-feira, 11 de abril de 2018 18:32:18 BRT, Stefan Blumentrath <<a href="mailto:Stefan.Blumentrath@nina.no">Stefan.Blumentrath@nina.no</a>> escreveu:
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p> </o:p></span></p>
</div>
<div>
<div id="yiv6359193583">
<div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Hi Bernado,</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Please find attached the «work-in-progress» version of v.rast.bufferstats for some more inspiration.</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">v.db.select -r does what you are looking for:</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><a href="https://grass.osgeo.org/grass74/manuals/v.db.select.html" target="_blank">https://grass.osgeo.org/grass74/manuals/v.db.select.html</a></span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">However, if the polygons you are working with don`t overlap, looping should not be required, and you should be able to use r.univar
with zones or r.stats for all polygons at once…</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Cheers</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Stefan
</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<p class="yiv6359193583msonormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
<div id="yiv6359193583yqt84316">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="yiv6359193583msonormal"><b><span lang="EN-US" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A">From:</span></b><span lang="EN-US" style="font-size:11.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> Bernardo Santos <<a href="mailto:bernardo_brandaum@yahoo.com.br">bernardo_brandaum@yahoo.com.br</a>>
<br>
<b>Sent:</b> onsdag 11. april 2018 20.59<br>
<b>To:</b> Helmut Kudrnovsky <<a href="mailto:hellik@web.de">hellik@web.de</a>>; <a href="mailto:grass-user@lists.osgeo.org">
grass-user@lists.osgeo.org</a>; Stefan Blumentrath <<a href="mailto:Stefan.Blumentrath@nina.no">Stefan.Blumentrath@nina.no</a>><br>
<b>Subject:</b> Re: [GRASS-user] zonal statistics/metrics - beyond simple statistics</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><o:p></o:p></span></p>
</div>
</div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
<div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Hi Helmut and Stefan,<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">thanks for sharing that with me, it is good to know that there are similar
</span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:black">ongoing </span><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">approaches to solve related issues.<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Helmut,<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">very nice addon. However, it seems to me that the part on calculating statistics is still based on v.rast.stats, am I right?<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Stefan, the question you pose is indeed very related. I took a better look at my code and I noticed that what really takes time is not the process
of making a mask, but what comes before: the rasterization of one of the polygons of the input vector.<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">What I do is:<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">1) g.region using the vector layer, aligning it to the first of the input rasters<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">2) v.to.rast selecting only one of the polygons at a time from the vector layer<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">3) r.mask using the rasterized polygon<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">4) g.region zoom=rasterized_polygon<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">5) calculate any function for all raster maps (in principle using a loop), using this small region and the mask, and attaching the results to the
attribute table<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">6) repeat 1-5 for all polygons in the input vector<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">However, I noticed now that what takes time is v.rast.stats, since it depends on the whole region selected, which in my case is much bigger than
a single polygon (the vector is a set of ~6,000 small polygons).<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Do you guys know if there is a way of using a single polygon from a vector to define the region using something like g.region?<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">[this would be really great!!]<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">something like<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">g.region vector=vector_of_interest cat=1<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Best,<o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Bernardo<o:p></o:p></span></p>
</div>
<div id="yiv6359193583yahoo_quoted_3745491540">
<div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Em terça-feira, 10 de abril de 2018 06:01:34 BRT, Stefan Blumentrath <<a href="mailto:Stefan.Blumentrath@nina.no" target="_blank">Stefan.Blumentrath@nina.no</a>>
escreveu: <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"> <o:p></o:p></span></p>
</div>
<div>
<div>
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A">Hei Bernardo,<br>
<br>
Just for the record: I am currently working on something similar / related.<br>
<br>
First of all I would like to improve speed of v.rast.stats for multiple inputs:<br>
<a href="https://www.mail-archive.com/grass-dev@lists.osgeo.org/msg52562.html%20" target="_blank">https://www.mail-archive.com/grass-dev@lists.osgeo.org/msg52562.html
</a>and <br>
<a href="https://trac.osgeo.org/grass/ticket/3523" target="_blank">https://trac.osgeo.org/grass/ticket/3523</a><br>
<br>
Adding a functionality to "tabulate areas" or "count categories" is a next step I have in mind which I am working on in v.rast.bufferstats (will be a port of v.what.rast.buffer [1] to GRASS 7 / pygrass (with some enhancements)). Once I have a good solution
there I would like to see if it can be moved to v.rast.stats. Support for dbf driver is however a challenge...<br>
<br>
I will add my "work in progress" script to github, so you can have a look if you like.<br>
<br>
Cheers<br>
Stefan<br>
<br>
1: <a href="https://grass.osgeo.org/grass64/manuals/addons/" target="_blank">https://grass.osgeo.org/grass64/manuals/addons/</a><br>
<br>
-----Original Message-----<br>
From: grass-user <<a href="mailto:grass-user-bounces@lists.osgeo.org" target="_blank">grass-user-bounces@lists.osgeo.org</a>> On Behalf Of Helmut Kudrnovsky<br>
Sent: mandag 9. april 2018 23.19<br>
To: <a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
Subject: Re: [GRASS-user] zonal statistics/metrics - beyond simple statistics<br>
<br>
Bernardo Santos wrote<br>
> Dear GRASS list,<br>
> I am developing a Python script to be able to calculate (virtually <br>
> any) metrics or statistics for zones/polygons in a vector - in analogy <br>
> to zonal statistics (such as v.rast.stats).The idea is that one can <br>
> calculate raster-based metrics (such as proportion of habitat, number <br>
> of patches, or any metric that can be formalized as a function that <br>
> takes some information from the input raster and returns a value) for <br>
> each polygon in the vector, and this is updated as a value in a newly <br>
> created column in the attribute table of this vector.<br>
> Is there already anything like that (some addon/module) that I am <br>
> missing, just to avoid re-doing something already created?<br>
> If not, what I am doing is to create a loop over all the features in a <br>
> vector, and for each one I zoom and use the polygon to define a mask <br>
> (using r.mask), so that the calculation of the selected metric is <br>
> performed only over that polygon, and this process is repeated.The <br>
> script allows one to calculate metrics/statistics for multiple raster <br>
> maps at once, and to incorporate other function for statistics also. <br>
> It may be found here:<a href="https://github.com/LEEClab/GeneralizedZonalStats" target="_blank">https://github.com/LEEClab/GeneralizedZonalStats</a><br>
> <br>
> For small vectors this works nicely and I believe it has a great <br>
> potential. However, when I try to calculate metrics for a large <br>
> dataset (e.g. the Brazilian map of cities, with almost 6,000 polygons) <br>
> - and that is when the tool would be interesting -, the process of <br>
> creating each mask takes too long (387 steps), and the tool becomes kind of useless.<br>
> Then I have two questions:- First, what drives the number of steps <br>
> GRASS takes to create a mask? Why it is very small for some maps but <br>
> very large for others? I quite don't understand that yet.- Do you <br>
> think of a easier or faster way of doing the same thing (instead of using masks)?<br>
> v.rast.stats seems to use r.univar and the option 'zones' for doing <br>
> so, but then one gets restricted to the statistics calculated by this module.<br>
> Any help or comment would be very welcome!<br>
> Best,Bernardo Niebuhr<br>
> _______________________________________________<br>
> grass-user mailing list<br>
<br>
> <a href="mailto:grass-user@.osgeo" target="_blank">grass-user@.osgeo</a><br>
<br>
> <a href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
<br>
have look at<br>
<br>
<a href="https://grass.osgeo.org/grass74/manuals/addons/v.habitat.dem.html" target="_blank">https://grass.osgeo.org/grass74/manuals/addons/v.habitat.dem.html</a><br>
<br>
where I've coded some DEM derived stats and characteristics for polygones.<br>
<br>
<br>
<br>
<br>
-----<br>
best regards<br>
Helmut<br>
--<br>
Sent from: <a href="http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html" target="_blank">
http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html</a><br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><o:p></o:p></span></p>
<div id="yiv6359193583yqtfd18594">
<p class="yiv6359193583msonormal"><span style="font-size:10.0pt;font-family:"Helvetica",sans-serif;color:#26282A"><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org" target="_blank">grass-user@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/grass-user</a><o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>