<!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 > ensgrass.$DTYPE.out<br>
<br>
then outside the script above:<br>
<br>
ensgrass.ksh PCP latlong.out<br>
fname=qpf.$dd.$ff.$mx$mnum<br>
join basins.out ensgrass.$DTYPE.out > 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 WENM1<br>
2 DOVM1<br>
3 WYMM1<br>
4 EBKV1<br>
5 EDDM1<br>
6 ROUN6<br>
7 NSTN3<br>
8 NANM1<br>
9 PITM1<br>
10 SIDM1<br>
11 SKOM1<br>
12 MERM1<br>
13 CZRN6<br>
14 NTYV1<br>
15 SWAV1<br>
16 GEOV1<br>
17 RMFM1<br>
18 JONV1<br>
19 ESSV1<br>
20 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:
"Arial","sans-serif"; 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: "Times
New Roman","serif";" lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
normal;"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; 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:
"Arial","sans-serif"; color: black;"
lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
normal;"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; 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:
"Arial","sans-serif"; color: black;"
lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
normal;"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; 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:
"Arial","sans-serif"; color: black;"
lang="EN-US"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
normal;"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; 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:
"Arial","sans-serif"; color: black;"> </span></p>
<p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height:
normal;"><span style="font-size: 10pt; font-family:
"Arial","sans-serif"; 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>