Frederico,

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.

Another possibility is something like this (snippit from a GRASS script in a Linux environment), that we have used where speed is critical:


#
# remove previous vector file and create new from precip file, where $DTYPE and $INFILE are script inputs; # so, if you are reading rasters rater than point data, some coding can be eliminated
#
g.remove vect=ens$DTYPE,basevect$DTYPE
v.in.ascii input=$INFILE output=ens$DTYPE format=point x=3 y=2 z=4 cat=0

# create raster from vector points and display
g.remove rast=ensrast$DTYPE,basemap,ensint$DTYPE,ensavg$DTYPE

# Adjusting the number of points for weight calculations
v.surf.idw -n input=ens$DTYPE output=ensrast$DTYPE npoints=4 col=dbl_3
g.copy vect=$BASINVECT,basevect$DTYPE
echo "Before r.mapcalc"
r.mapcalc "ensint$DTYPE=round(100*ensrast$DTYPE)"
echo "After r.mapcalc"
v.build map=basevect$DTYPE
r.statistics base=$BASINVECT cover=ensint$DTYPE method=average output=ensavg$DTYPE
r.cats map=ensavg$DTYPE > ensgrass.$DTYPE.out

then outside the script above:

     ensgrass.ksh PCP latlong.out
     fname=qpf.$dd.$ff.$mx$mnum
     join basins.out ensgrass.$DTYPE.out > output/$fname

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

basins.out is a text file that looks like this:

1    WENM1
2    DOVM1
3    WYMM1
4    EBKV1
5    EDDM1
6    ROUN6
7    NSTN3
8    NANM1
9    PITM1
10    SIDM1
11    SKOM1
12    MERM1
13    CZRN6
14    NTYV1
15    SWAV1
16    GEOV1
17    RMFM1
18    JONV1
19    ESSV1
20    AUSN6



Tom

On 6/21/11 10:03 AM, Frederico Mestre wrote:

Hello,

I'm trying to retrieve some statistics from several rasters, based on overlaying vectors.

I'm using v.rast.stats but it is very slow. Is there another way?

I read something about Starspan, a software that does this same thing faster, but I can,t find it to download.

Can anybody help?

Frederico Mestre


_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user


--
Thomas E Adams
National Weather Service
Ohio River Forecast Center
1901 South State Route 134
Wilmington, OH 45177

EMAIL:  [email protected]

VOICE:  937-383-0528
FAX:    937-383-0033

_______________________________________________
grass-user mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-user

Reply via email to