<div dir="ltr"><div>I haven't tested it, but the fastest way could be to rasterize your polygon layer (using the resolution of the input raster or higher resolution - make sure to assign an unique id to each grid cell before) and then use r.stats<br><br>r.stats -a -p input=rasterized_polygon,raster<br><br></div>Rgds,<br><br>Paulo<br><div><div><br><div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 11, 2015 at 12:15 PM, Margherita Di Leo <span dir="ltr"><<a href="mailto:diregola@gmail.com" target="_blank">diregola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>I have to calculate the percentage of given class of a raster within the polygons given in a vector (a regular grid). Since I'm dealing with large files and operations repeated in a chain, i should be focusing on what is the optimal (fastest) option to do that. I could vectorize the raster and use v.overlay and v.to.db, or using v.rast.stats i can count out the number of cells (should i use number for that or sum?) and then divide per area of the grid. Any better idea? </div><div><br></div><div>Thank you in advance<br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><font color="#666666">Best regards,</font></div><div><font color="#666666"><br></font></div><div><font color="#666666">Dr. Margherita DI LEO </font></div><div><span style="color:rgb(102,102,102);font-family:arial;font-size:small">Scientific / technical project officer</span><br></div><div><font color="#666666"><br></font></div><div><font color="#666666">European Commission - DG JRC </font></div><div><font color="#666666">Institute for Environment and Sustainability (IES)</font></div><div><font color="#666666">Via Fermi, 2749</font></div><div><font color="#666666">I-21027 Ispra (VA) - Italy - TP 261</font></div><div><font color="#666666"> </font></div><div><font color="#666666">Tel. +39 0332 78 3600 </font></div><div><font color="#666666"><a href="mailto:margherita.di-leo@jrc.ec.europa.eu" target="_blank">margherita.di-leo@jrc.ec.europa.eu</a></font></div><div><font color="#666666"><br></font></div><div><font color="#666666">Disclaimer: The views expressed are purely those of the writer and may not in any circumstance be regarded as stating an official position of the European Commission.</font></div></div></div>
</div></div>
<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" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br></blockquote></div><br></div></div></div></div></div>