[GRASS5] s.surf.idw improvements and region settings

Paul Kelly paul-grass at stjohnspoint.co.uk
Thu Mar 27 06:06:34 EST 2003

Hello everybody
I've made an improvement to s.surf.idw to greatly improve its efficiency
when dealing with a large number of sites for interpolation, which I'm
thinking of commiting to CVS. The improvement is that when initially
reading the sites file it indexes all the sites according to what cell they
fall into, so that when it is later searching for the 12 nearest sites it
doesn't have to search through them all, just those indexed to the current
and nearby cells. Currently for each output cell it searches through all
the sites in the input file and calculates the distance to each one in
order to find the 12 nearest sites. With a few hundred thousand sites this
can cause it to take hours to run; with the improvements it takes only a
few minutes.

In doing this I've been thinking about the inconsistency between
s.surf.idw and s.surf.rst with regard to the sites used in the
interpolation. s.surf.rst only uses sites which fall inside the current
region, while s.surf.idw currently uses all the sites in the input sites
file no matter where they are. If there are a lot of sites outside the
region this can use a huge amount of memory and as part of my improvements
it only reads into memory sites that are within the region bounds (i.e.
consistent with s.surf.rst) but I wondered is this an acceptable change in

If sites outside the interpolation region are required to be
included it can be done by setting a bigger region and using a mask for
the interpolation region. I think this is how it would be done with
s.surf.rst. Incidentally, s.surf.rst has a special command-line option to
specify a maskmap while s.surf.idw simply honours the conventional GRASS
MASK raster layer. Is there a reason for this other inconsistency?

With a bit more work it might be possible to add a command-line switch
that enables the old behaviour (I would need to think about it), but I
don't really think this is necessary as it can be worked around (I will
explain this in the man page) and especially as the new behaviour would
make it consistent with s.surf.rst.

If there aren't any objections I will commit the improvements to CVS in a
day or two.


More information about the grass-dev mailing list