[GRASS-user] making fcell raster maps using climate data

Hamish hamish_b at yahoo.com
Mon May 30 06:09:20 EDT 2011


Pierre wrote:
> There actually more than one station in Bullent's data set,
> but the difficulty that one raster layer must be interpolated for
> each month of each year that has been modelled. Thus a bit of data
> tweaking in R.
> No idea if awk/sed or any of those magic unix tools I don't
> know much about could do the trick and avoid the call to R?

There's very little those power tools can't do to text files with a few
lines of code, but if one is already an expert in R, Python, Matlab, or
some other swiss army knife-of-a-scripting language, for one-offs or
prototypes you might as well use the tool you're most familiar with.
Many roads to get to Rome.


But perhaps, in this case & if the dataset is < ~3 million points, GRASS's
tools are the cleanest of all. As the original fit into a spreadsheet
I'd expect GRASS would have no problem with it.
Consider:


#make some test data, all at the same point in space
GRASS> cat << EOF > testpts
#cat,e,n,year_bp,temp_F
1,10,10,-100,32.1
2,10,10,-200,33.2
3,10,10,-300,34.3
EOF

#import them
GRASS> v.in.ascii in=testpts out=testpts cat=1 x=2 y=3 fs=, \
  columns='cat integer, easting double precision, northing double precision, year_bp integer, temp_f double precision'

#show the database
GRASS> v.db.select testpts
cat|easting|northing|year_bp|temp_f
1|10|10|-100|32.1
2|10|10|-200|33.2
3|10|10|-300|34.3

#select only the points matching a certain year into a new map
GRASS> v.extract in=testpts out=testpts_200bp where='year_bp = -200'

#show the database for the extraction
GRASS> v.db.select testpts_200bp
cat|easting|northing|year_bp|temp_f
2|10|10|-200|33.2

#interpolate from that extraction
GRASS> v.surf.rst in=testpts_200bp zcolumn=temp_f  # ...


or maybe even skip the v.extract step and do the SQL query from the
original import vector map directly in v.surf.rst:

GRASS> v.surf.rst in=testpts_200bp zcolumn=temp_f where='year_bp = -200' # ...
?


of course you'll need a database for that so it won't work well for
millions and millions of data points (ie LIDAR)- awk or some custom C
program (etc) would then be needed to do the split efficiently. probably
python would do ok too.

I note that v.to.db has a where= option; I don't know about Excel but 
OpenOffice can save directly to a DBF file. But again, many roads..


Hamish



More information about the grass-user mailing list