<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    Frederico,<br>
    <br>
    One possible way is to generate a raster MASK file from the vector
    data and, using the mask for each polygonal area and R, calculate
    statistics that way. Although, honestly, I don't know if that would
    be faster or not.<br>
    <br>
    Another possibility is something like this (snippit from a GRASS
    script in a Linux environment), that we have used where speed is
    critical:<br>
    <br>
    <br>
    #<br>
    # remove previous vector file and create new from precip file, where
    $DTYPE and $INFILE are script inputs;<br>
    # so, if you are reading rasters rater than point data, some coding
    can be eliminated<br>
    #<br>
    g.remove vect=ens$DTYPE,basevect$DTYPE<br>
    v.in.ascii input=$INFILE output=ens$DTYPE format=point x=3 y=2 z=4
    cat=0<br>
    <br>
    # create raster from vector points and display<br>
    g.remove rast=ensrast$DTYPE,basemap,ensint$DTYPE,ensavg$DTYPE<br>
    <br>
    # Adjusting the number of points for weight calculations<br>
    v.surf.idw -n input=ens$DTYPE output=ensrast$DTYPE npoints=4
    col=dbl_3<br>
    g.copy vect=$BASINVECT,basevect$DTYPE<br>
    echo "Before r.mapcalc"<br>
    r.mapcalc "ensint$DTYPE=round(100*ensrast$DTYPE)"<br>
    echo "After r.mapcalc"<br>
    v.build map=basevect$DTYPE<br>
    r.statistics base=$BASINVECT cover=ensint$DTYPE method=average
    output=ensavg$DTYPE<br>
    r.cats map=ensavg$DTYPE &gt; ensgrass.$DTYPE.out<br>
    <br>
    then outside the script above:<br>
    <br>
    &nbsp;&nbsp;&nbsp;&nbsp; ensgrass.ksh PCP latlong.out<br>
    &nbsp;&nbsp;&nbsp;&nbsp; fname=qpf.$dd.$ff.$mx$mnum<br>
    &nbsp;&nbsp;&nbsp;&nbsp; join basins.out ensgrass.$DTYPE.out &gt; output/$fname<br>
    <br>
    where ensgrass.ksh is the calling script the the GRASS snippit
    above. 'PCP' is a keyword and 'latlong.out' is the input file to
    ensgrass.ksh. The end result, following the join, is that you get
    average values for the polygon areas associated by the polygon IDs
    in basins.out<br>
    <br>
    basins.out is a text file that looks like this:<br>
    <br>
    1&nbsp;&nbsp;&nbsp; WENM1<br>
    2&nbsp;&nbsp;&nbsp; DOVM1<br>
    3&nbsp;&nbsp;&nbsp; WYMM1<br>
    4&nbsp;&nbsp;&nbsp; EBKV1<br>
    5&nbsp;&nbsp;&nbsp; EDDM1<br>
    6&nbsp;&nbsp;&nbsp; ROUN6<br>
    7&nbsp;&nbsp;&nbsp; NSTN3<br>
    8&nbsp;&nbsp;&nbsp; NANM1<br>
    9&nbsp;&nbsp;&nbsp; PITM1<br>
    10&nbsp;&nbsp;&nbsp; SIDM1<br>
    11&nbsp;&nbsp;&nbsp; SKOM1<br>
    12&nbsp;&nbsp;&nbsp; MERM1<br>
    13&nbsp;&nbsp;&nbsp; CZRN6<br>
    14&nbsp;&nbsp;&nbsp; NTYV1<br>
    15&nbsp;&nbsp;&nbsp; SWAV1<br>
    16&nbsp;&nbsp;&nbsp; GEOV1<br>
    17&nbsp;&nbsp;&nbsp; RMFM1<br>
    18&nbsp;&nbsp;&nbsp; JONV1<br>
    19&nbsp;&nbsp;&nbsp; ESSV1<br>
    20&nbsp;&nbsp;&nbsp; AUSN6<br>
    <br>
    <br>
    <br>
    Tom<br>
    <br>
    On 6/21/11 10:03 AM, Frederico Mestre wrote:
    <blockquote
      cite="mid:BANLkTi=THLFtiECpBHqyTydK-zOUVC=Ebg@mail.gmail.com"
      type="cite">
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">Hello,</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 12pt; font-family: &quot;Times
          New Roman&quot;,&quot;serif&quot;;" lang="EN-US">&nbsp;</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">I'm trying to retrieve some statistics from
          several
          rasters, based on overlaying vectors.</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">&nbsp;</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">I'm using v.rast.stats but it is very slow. Is
          there
          another way?</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">&nbsp;</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">I read something about Starspan, a software that
          does
          this same thing faster, but I can,t find it to download.</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;"
          lang="EN-US">&nbsp;</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;">Can
          anybody help?</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: black;">&nbsp;</span></p>
      <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
        normal;"><span style="font-size: 10pt; font-family:
          &quot;Arial&quot;,&quot;sans-serif&quot;; color: rgb(136, 136,
          136);">Frederico Mestre</span></p>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
grass-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/grass-user">http://lists.osgeo.org/mailman/listinfo/grass-user</a>
</pre>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:        <a class="moz-txt-link-abbreviated" href="mailto:thomas.adams@noaa.gov">thomas.adams@noaa.gov</a>

VOICE:        937-383-0528
FAX:        937-383-0033</pre>
  </body>
</html>