GRASS logo

NAME - IDW interpolation, but distance is cost to get to any other site.


vector, surface, interpolation, ICW

SYNOPSIS --help [-r] input=string column=string output=string cost_map=string [friction=float] [layer=integer] [where=string] [post_mask=string] [workers=integer] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Use (d^n)*log(d) instead of 1/(d^n) for radial basis function
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=string [required]
Name of existing vector points map containing seed data
column=string [required]
Column name in points map that contains data values
output=string [required]
Name for output raster map
cost_map=string [required]
Name of existing raster map containing cost information
Friction of distance, (the 'n' in 1/d^n)
Options: 1-6
Default: 2
Layer number of data in points map
Default: 1
WHERE conditions of SQL query statement without 'where' keyword
Example: income < 1000 and inhab >= 10000
Name of existing raster map to be used as post-processing MASK
Number of parallel processes to launch
Options: 1-256
Default: 1

Table of contents


Inverse cost weighting is like inverse distance weighted (IDW) interpolation, but uses cost instead of shortest Euclidean distance. In this way solid barriers and molasses zones may be correctly taken into account.

Input data points do not need to have direct line of sight to each other. This is interpolation "as the fish swims", not "as the crow flies", and can see around headlands or across land-bridges without polluting over barriers which the natural value (or flightless bird) can not cross.

It was initially written to interpolate water chemistry in two parallel arms of a fjord, but may just as well be used for population abundance constrained by topography, or in studies of archeologic technology transfer.


In the simplest case, the cost map will just be a mask raster with values of 1 in areas to interpolate, and NULL in impenetrable areas. Fancier cost maps can be used, for example, to make it more expensive for a measured pollutant to diffuse upstream in an estuary, or to make it more expensive for a stone tool technology to cross waterways.

Since generating cost maps can take a long time, it is recommended to keep the raster region relatively small and limit the number of starting points to less than 500.

Higher values of friction will help limit unconstrained boundary effects at the edges of your coverage, but will incur more of a stepped transition between sites.

The post_mask, if given, is applied after the interpolation is complete. A common use for that might be to only present data within a certain distance (thus confidence) of an actual sampling station. In that case the r.cost module can be used to create the mask.

This module writes lots of temporary files and so can be rather disk I/O intensive. If you are running it many times in a big loop you may want to try setting up a RAM-disk to put the mapset in (on UNIX symlinking back into the location is ok), or adjust the disk-cache flushing timer to be slightly longer than one iteration of the script.
To do this on Linux you can tune the /proc/sys/vm/dirty_expire_centisecs kernel control. The default is to keep files in memory a maximum of 30 seconds before writing them to disk, although if you are short on free RAM the kernel may write to disk long before that timeout is reached.

By default the module will run serially. To run in parallel set the workers parameter to the desired value (typically the number of cores in your CPU). Alternatively, if the WORKERS environment variable is set, the number of concurrent processes will be set at that number of jobs.


In this example we'll generate some fake island barriers from the standard North Carolina GRASS dataset, then interpolate a continuous variable between given point stations. We'll use rainfall, but for the purposes of the exercise pretend it is a nutrient concentration in our fake wayerway. Point data stations outside of the current region or in NULL areas of the cost_map will be ignored.
# set up a fake sea with islands:
g.region n=276000 s=144500 w=122000 e=338500 res=500
r.mapcalc "pseudo_elev = elev_state_500m - 1100"
r.colors pseudo_elev color=etopo2
r.mapcalc "navigable_mask = if(pseudo_elev < 0, 1, null())"

# pick a data column from the points vector: -c precip_30ynormals

# run the interpolation: input=precip_30ynormals column=annual output=annual_interp.3 \
   cost_map=navigable_mask friction=3 --verbose

# equalize colors to show maximum detail:
r.colors -e annual_interp.3 color=bcyr

# display results in a GRASS monitor:
d.mon wx0
d.erase black
d.rast annual_interp.3
d.vect precip_30ynormals fcolor=red icon=basic/circle
d.legend annual_interp.3 at=48.4,94.8,3.4,6.0


The method was first described in Wing et. al 2004, with further comments and examples in report 3 of that series, 2005. Ducke and Rassmann 2010 (in German) describe a novel use of the approach to study prehistoric movement corridors of early Bronze Age technology through Europe.



Hamish Bowman
Department of Marine Science,
Dunedin, New Zealand

Last changed: $Date: 2016-07-30 22:46:03 +0200 (Sat, 30 Jul 2016) $


Available at: source code (history)

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

© 2003-2017 GRASS Development Team, GRASS GIS 7.2.3svn Reference Manual