bi-linear interpolation from a coarser to finer grid

James Darrell McCauley mccauley at
Fri Jul 28 14:54:27 EDT 1995

Eric Small (esmall at 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 | 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}' \
    | junk
# convert "junk" sites to raster "newmap" 
# clean up
 g.remove sites=junk,newmap

s.sample may be found at

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.

James Darrell McCauley, PhD 
Agricultural & Biological Engineering mccauley at
Purdue University                     tel: 317.494.1198 fax: 317.496.1115

More information about the grass-user mailing list