bi-linear interpolation from a coarser to finer grid

James Darrell McCauley mccauley at ecn.purdue.edu
Fri Jul 28 14:54:27 EDT 1995


Eric Small (esmall at rupture.ucsc.edu) writes on 26 July 1995:
>does anyone know how to bi-linearly interpolate from a 7:30 x 4:30 (degrees) raster
>to a 2 X 2 (degree) raster ?? 

Here's one way (off the cuff, untested):
# change resolution
 g.region res=2 
# get cell coordinates
 r.stats -1g oldmap | s.in.ascii junk
# sample "oldmap" at these coordinates
 s.sample -B i=junk o=newmap rast=oldmap
# change the format of the sites list "newmap"
 s.out.ascii -d newmap | awk '{printf "%s %s #%d $1,$2,,$3}' \
    | s.in.ascii junk
# convert "junk" sites to raster "newmap"
 s.menu 
# clean up
 g.remove sites=junk,newmap

s.sample may be found at 
ftp://pasture.ecn.purdue.edu/pub/mccauley/grass/s.sample.tar.gz

s.sample will also do cubic convolution.

However, if you'd like to use something better than bilinear,
r.resample.tps may meet your needs. 
ftp://moon.cecer.army.mil/grass/incoming/interp_lib.tar.Z

Darrell
-- 
James Darrell McCauley, PhD           http://soils.ecn.purdue.edu/~mccauley/
Agricultural & Biological Engineering mccauley at ecn.purdue.edu
Purdue University                     tel: 317.494.1198 fax: 317.496.1115



More information about the grass-user mailing list