[GRASSLIST:2510] Re: Interpolate from database

Hamish hamish_nospam at yahoo.com
Sat Feb 7 10:11:36 EST 2004


> I have a bunch of meteorological stations (157) on a
> postgres table and their respective DAILY data
> (precip, temp, wind) on another table. The thing is, I
> need to create daily surface maps, interpolating those
> points in the database. Is there a way to do this in
> GRASS, that is, input the points from the SQL table,
> interpolate the data for one day and get a surface,
> change the day and interpolate again, and again, for
> about 1 year worth of data? Do I need grass 5.7? 5.3?


Yea, sure. Works really well once you have a script written.
Time to learn some bash scripting though!

You can use 5.0, but I suggest using 5.3+, so that you can compile
r.series which lets you do stats on the year's worth of resultant maps
(after increasing r.series' MAXFILES to something bigger than 365!).

general idea is to extract a single day's data to a sites file, do the
interpolation, & repeat.

If you have Markus & Helena's hardbound GRASS book, there's an example 
there regarding r.sun I think.


general idea:

#!/bin/bash
i=1
while [ $i -le 365 ] ; do
    # generate map names convenient for xganim or r.out.mpeg
    DAY=`echo $i | awk '{printf "%03i", $1}'`
    echo
    echo "Computing radiation for day $DAY..."

    sql_extraction_command day=$i sites_out=rain.$DAY
# maybe dump to temp. file & feed that into s.in.ascii ?
    s.surf.idw sites_in=rain.$DAY rast_out=insitu_data.$DAY

    i=`expr $i + 1`
done
r.series input="`g.mlist pattern='insitu_data.*' sep=,`" \
    output=insitu_data.stddev method=stddev




good luck,
Hamish




More information about the grass-user mailing list