[GRASS-user] [GRASSLIST:1137] Re: Qn. on extracting from multiple rasters, data corresponding to vector polygons

Jachym Cepicky jachym.cepicky at centrum.cz
Tue Jun 27 08:12:43 EDT 2006


Hallo,

On Tue, Jun 27, 2006 at 04:16:38PM +0530, Vishal Mehta wrote:
> Hi all,
> 
> I have a vector polygon shapefile which contains 8 polygons (each watershed
> is a polygon). I also have some 100 GRASS raster files of environmental data
> (rainfall, temperature etc).
> 
> Whats the best way to extract for each watershed, the corresponding average
> data from each raster file and put it in a text file?
> 
> I've looked at v.what.rast but it seems to be quite cumbersome for this
> application. I'm using Grass 6.0.1 on Ubuntu linux.
> 
> cheers,
> vishal

v.type in=polygons out=polygons2 type=centroid,point
v.to.rast in=polygons2 out=wathershed use=cat
r.average base=wathershed cover=rainfalls out=rainfalls.avg
echo "ALTER TABLE polygons2 ADD COLUMN rainfalls double"|db.execute
v.what.vect vect=polygons2 rast=rainfalls.avg coulmn=rainfalls
...

v.type in=polygons2 out=polygons3 type=point,centroid
d.vect polygons3
d.what.vect polygons3


in the batch:

#----
# convert centorids to points
v.type in=polygons out=polygons2 type=centroid,point
v.to.rast in=polygons2 out=wathershed use=cat

# make 100 rasters
for raster in $( g.mlist rast ); do
    echo "Working on: $raster"
    r.average base=wathershed cover=$raster out=$raster.avg
    echo "ALTER TABLE polygons2 ADD COLUMN $raster double"|db.execute
    v.what.vect vect=polygons2 rast=$raster.avg coulmn=$raster

# convert points to centroids
v.type in=polygons2 out=polygons3 type=point,centroid
d.vect polygons3
d.what.vect polygons3
#----

copy & paste

jachym

-- 
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------   
OFFICE:                                     
GDF-Hannover
Mengendamm 16d
30177 Hannover
Germany
e-mail: cepicky at gdf-hannover.de
URL:    http://gdf-hannover.de
Tel.:   +49 511-39088507
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20060627/4e26c668/attachment.bin


More information about the grass-user mailing list