[GRASS-user] [GRASSLIST:1140] Re: Qn. on extracting from multiple
rasters, data corresponding to vector polygons
Vishal Mehta
vishalm1975 at gmail.com
Wed Jun 28 03:02:33 EDT 2006
Thanks all (esp. Jachym, Dylan, Jonathan)
Dylan/Jonathan, I havent tried Starspan, but it
looks good. i'll get into it if i find i have to. I cant compile from
sourcecode since i'm not that Linux savvy.
Jachym, I tried your approach on a small set of 12 rasters. v.what.vect is
not there in my Grass 6.0.1; but i was able to do the same thing with
v.what.rast
Basically values from each raster were added on as a column in the vector
attribute table. Thanks Jachym!
However, even with just 12 rasters, it took a bit of time (~10 seconds).
With some 100 rasters to process at a time, I have the following doubts:
1. Can the vector attribute table handle 100 additional tables, or is there
a limit?
2. My rasters are large, covering south asia (60E-100E, 5N-45N; 0.5 degree
resolution). My vectors are very small (covering small part of south-west
India). Perhaps this effects the processing time..should i mask the rasters
and then do the adding of columns?
3. Since my watershed are small, most fall within one pixel. When they do
cross 2 pixels, the v.to.rast clips the raster watershed to one pixel. Any
suggestion on perhaps better ways of handling this?
Thanks very much!
cheers,
vishal
On 6/27/06, Jachym Cepicky <jachym.cepicky at centrum.cz> wrote:
>
> 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
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.3 (GNU/Linux)
>
> iD8DBQFEoSC6yKt0uAjU4I8RAs7bAJ0VbEJZ7763uMKCL7HPRQvCk7XztQCfarwE
> yKmI8KxGdTk0qskBiEFSE2E=
> =CJ47
> -----END PGP SIGNATURE-----
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20060628/d826b3b9/attachment.html
More information about the grass-user
mailing list