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.
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.
On Tuesday 27 June 2006 03:46, 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
if you have the ability to compile from source code, try starspan.
We designed starspan to do exactly this - one of these days
we'll mod it so it works from within grass: starspan.casil.ucdavis.edu .
--j
--
Jonathan A. Greenberg, PhD
NRC Research Associate
NASA Ames Research Center
MS 242-4
Moffett Field, CA 94035-1000
Phone: 415-794-5043
AIM: jgrn3007
MSN: jgrn3007@hotmail.com
_____
From: owner-GRASSLIST@baylor.edu [mailto:owner-GRASSLIST@baylor.edu] On
Behalf Of Vishal Mehta
Sent: Tuesday, June 27, 2006 3:47 AM
To: GRASS Users list
Subject: [GRASSLIST:1135] Qn. on extracting from multiple rasters, data
corresponding to vector polygons
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.
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:
Can the vector attribute table handle 100 additional tables, or is there a limit?
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?
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?
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.
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.
I think this can be easily done.
why not just
g.region rast=biggest_map
v.to.rast in=vectmap out=watersheds use=cat # or attr if ID column exists
r.mapcalc "MASK=if(watersheds == 1, 1, null() )"
r.univar rainfall
for MAP in `g.mlist type=rast pat=* fs=space` ; do #g.region rast=$MAP # adjust to match res of each map
MEAN=`r.univar -g $MAP | grep '^mean=' | cut -f2 -d=`
echo "$WATERSHED|$MAP|$MEAN" >> results.txt
done
done
g.remove MASK
if maps are all different sizes and resolutions do the v.to.rast
step at the finest resolution to avoid aliasing problems.
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?
add in a step after MASK creation:
g.region zoom=MASK res=0.5 -a
leave out the g.mlist sep=space, it uses the whole word!
`g.mlist pat='*'` is enough.
Hamish
ps - new mailing list address: grassuser at grass.itc.it
Hi all,
I had, with your help, added 500 columns of rain data from 500 corresponding rasters, t0 my vector map of 8 watersheds.
Now i want to add another 500 columns to the same vector map, but from different 100 rasters, namely derived reference ET maps i have created.
My qna are:
Should i use the same table but first connect to a different empty ‘layer’ first using v.db.connect?
If i do the above, will i be able to extract individual layers of the table in openoffice calc or Excel?
i was going to just copy my vector map and then delete the original 500 rain columns from the table, and then add the 500 ET columns- but i was not able to do it. i tried commands like
echo “DELETE COLUMN ‘Rain1’ FROM watershed8c” | db.execute
and
echo “DELETE FROM watershed8c COLUMN LIKE ‘rain’” | db.execute
but they did’nt work.
How do i delete say all columns that start with the text ‘rain’ from a table?
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?
add in a step after MASK creation:
g.region zoom=MASK res=0.5 -a
leave out the g.mlist sep=space, it uses the whole word! g.mlist pat='*' is enough.
Hamish
ps - new mailing list address: grassuser at grass.itc.it
3. i was going to just copy my vector map and then delete the original
500 rain columns from the table, and then add the 500 ET columns- but
i was not able to do it. i tried commands like
echo "DELETE COLUMN 'Rain1' FROM watershed8c" | db.execute
and
echo "DELETE FROM watershed8c COLUMN LIKE 'rain'" | db.execute
but they did'nt work.
How do i delete say all columns that start with the text 'rain' from a
table?
I'm not sure, but the DBF driver may not support "DELETE" ?
Make a new table, copy columns you want to keep, v.db.droptable the old
table? or use another db?