Difference between revisions of "Interpolation"

From GRASS-Wiki
Jump to: navigation, search
(Reinterpolation of "sparse" (scattered points or lines) maps: v.surf.icw)
m (remove hardcoded version specific urls, use latest version)
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Resampling methods and interpolation in GRASS ==
+
== Resampling methods and interpolation in GRASS GIS ==
  
 
=== Reinterpolation of "filled" raster maps (continuous data) to a different resolution ===
 
=== Reinterpolation of "filled" raster maps (continuous data) to a different resolution ===
Line 7: Line 7:
 
* {{cmd|r.resamp.interp}} Resampling with nearest neighbor, bilinear, and bicubic method: method=nearest uses the same algorithm as {{cmd|r.resample}}, but not the same code, so it may not produce identical results in cases which are decided by the rounding of floating-point numbers. For {{cmd|r.resamp.interp}} method=bilinear and method=bicubic, the raster values are treated as samples at each raster cell's centre, defining a piecewise-continuous surface. The resulting raster values are obtained by sampling the surface at each region cell's centre. As the algorithm only interpolates, and doesn't extrapolate, a margin of 0.5 (for bilinear) or 1.5 (for bicubic) cells is lost from the extent of the original raster. Any samples taken within this margin will be null.
 
* {{cmd|r.resamp.interp}} Resampling with nearest neighbor, bilinear, and bicubic method: method=nearest uses the same algorithm as {{cmd|r.resample}}, but not the same code, so it may not produce identical results in cases which are decided by the rounding of floating-point numbers. For {{cmd|r.resamp.interp}} method=bilinear and method=bicubic, the raster values are treated as samples at each raster cell's centre, defining a piecewise-continuous surface. The resulting raster values are obtained by sampling the surface at each region cell's centre. As the algorithm only interpolates, and doesn't extrapolate, a margin of 0.5 (for bilinear) or 1.5 (for bicubic) cells is lost from the extent of the original raster. Any samples taken within this margin will be null.
 
* {{cmd|r.resamp.rst}} Regularized Spline with Tension (RST) interpolation 2D: Behaves similarly, i.e. it computes a surface assuming that the values are samples at each raster cell's centre, and samples the surface at each region cell's centre.
 
* {{cmd|r.resamp.rst}} Regularized Spline with Tension (RST) interpolation 2D: Behaves similarly, i.e. it computes a surface assuming that the values are samples at each raster cell's centre, and samples the surface at each region cell's centre.
 
+
* {{cmd|r.resamp.bspline}} resamples with bicubic or bilinear spline interpolation with Tykhonov regularization.
Only GRASS 7:
+
* {{cmd|r.resamp.filter}} resamples raster map layers using an analytic kernel. It offers box, bartlett, gauss, normal, hermite, sinc, lanczos1, lanczos2, lanczos3, hann, hamming, and blackman kernels.
* {{cmd|r.resamp.bspline|version=70}} resamples with bicubic or bilinear spline interpolation with Tykhonov regularization.
 
* {{cmd|r.resamp.filter|version=70}} resamples raster map layers using an analytic kernel. It offers box, bartlett, gauss, normal, hermite, sinc, lanczos1, lanczos2, lanczos3, hann, hamming, and blackman kernels.
 
  
 
==== Resampling of raster maps to coarser resolution ====
 
==== Resampling of raster maps to coarser resolution ====
Line 16: Line 14:
  
 
=== Reinterpolation of "sparse" (scattered points or lines) maps ===
 
=== Reinterpolation of "sparse" (scattered points or lines) maps ===
 +
<!-- screenshot moved up for cosmetic reasons -->
 +
[[Image:Inlets_03_SurfSal_icw_big.png|200px|right|thumb|v.surf.icw interpolating around barriers]]
  
* Inverse distance weighted average (IDW) interpolation ({{cmd|r.surf.idw}} and {{cmd|r.surf.idw2}})
+
* Inverse distance weighted average ({{wikipedia|Inverse_distance_weighting|IDW}}) interpolation ({{cmd|v.surf.idw}}, {{cmd|r.surf.idw}}, and {{AddonCmd|r.surf.idw2|version=7}} Addon)
* Interpolating from contour lines ({{cmd|r.contour}})
+
* Interpolating from contour lines ({{cmd|r.surf.contour}}), see [[Contour lines to DEM]]
* Interpolating from vector points with B-splines ({{cmd|v.surf.bspline}})
+
* Interpolating using {{wikipedia|Natural_neighbor}} method ({{AddonCmd|r.surf.nnbathy}}) 
* Interpolating from vector points with regularized splines with Tension ({{cmd|v.surf.rst}} and {{cmd|v.vol.rst}}), see also [[RST Spline Surfaces]]
+
* Interpolating from vector points with {{wikipedia|B-spline}}s ({{cmd|v.surf.bspline}})
* Interpolating from vector points with Kriging ({{cmd|v.krige|version=70}}, GRASS 7+)
+
* Interpolating from vector points with regularized splines with tension ({{cmd|v.surf.rst}} and {{cmd|v.vol.rst}}), see also [[RST Spline Surfaces]]
 +
* Interpolating from vector points with {{wikipedia|Kriging}} ({{cmd|v.krige}})
 
* Interpolating from vector points around barriers or cost surfaces ({{AddonCmd|v.surf.icw}})
 
* Interpolating from vector points around barriers or cost surfaces ({{AddonCmd|v.surf.icw}})
: [[Image:Inlets_03_SurfSal_icw_big.png|200px|right|thumb|v.surf.icw interpolating around barriers]]
+
 
 +
=== Heat maps (kernel density) ===
 +
* Create raster maps from vector points with ({{cmd|v.kernel}})
 +
* Inverse distance weighted average ({{wikipedia|Inverse_distance_weighting|IDW}}) interpolation ({{cmd|v.surf.idw}}, {{cmd|r.surf.idw}}, and {{cmd|r.surf.idw2}})
 +
 
 +
=== Binning ===
 +
 
 +
While not being a real interpolation method, raster binning generates raster maps from vector points.
 +
Vector points in XYZ format (CSV or ASCII file) can be rasterized (binning into raster cells) using univariate statistics:
 +
* see ({{cmd|r.in.xyz}})
 +
 
 +
=== Filling of holes ===
 +
 
 +
Sometimes no-data areas in raster maps (continuous surfaces) needs to be filled using interpolation:
 +
* see {{cmd|r.fillnulls}}
 +
 
 +
Optionally extra raster sample points can be generated from an auxiliary raster maps using {{cmd|r.random}}, merged into the target raster maps with {{cmd|r.patch}} and then filled using interpolation with {{cmd|r.fillnulls}}.
  
 
== Comparing original and interpolated data ==
 
== Comparing original and interpolated data ==
  
 
* Statistical assessment: Use {{cmd|r.mapcalc}} to calculate a differences map, then {{cmd|r.univar}} to calculates univariate statistics of the differences
 
* Statistical assessment: Use {{cmd|r.mapcalc}} to calculate a differences map, then {{cmd|r.univar}} to calculates univariate statistics of the differences
* Graphical comparison {{cmd|g.gui.mapswipe|version=70}} - Interactively compares two maps by swiping a visibility bar.
+
* Graphical comparison {{cmd|g.gui.mapswipe}} - Interactively compares two maps by swiping a visibility bar.
  
 
== See also ==
 
== See also ==
Line 37: Line 54:
 
* GRASS {{cmd|rasterintro}}
 
* GRASS {{cmd|rasterintro}}
 
* GRASS {{cmd|vectorintro}}
 
* GRASS {{cmd|vectorintro}}
 +
* [[Import XYZ]]
 +
* [[Grid registration]]
  
 
[[Category: Documentation]]
 
[[Category: Documentation]]
 
[[Category: FAQ]]
 
[[Category: FAQ]]
 
[[Category: Interpolation]]
 
[[Category: Interpolation]]

Latest revision as of 02:52, 4 December 2018

Resampling methods and interpolation in GRASS GIS

Reinterpolation of "filled" raster maps (continuous data) to a different resolution

Resampling of raster maps to finer resolution

  • r.resample uses the built-in resampling (nearest neighbor in GRASS 6), so it should produce identical results as the on-the-fly resampling done via the raster import modules.
  • r.resamp.interp Resampling with nearest neighbor, bilinear, and bicubic method: method=nearest uses the same algorithm as r.resample, but not the same code, so it may not produce identical results in cases which are decided by the rounding of floating-point numbers. For r.resamp.interp method=bilinear and method=bicubic, the raster values are treated as samples at each raster cell's centre, defining a piecewise-continuous surface. The resulting raster values are obtained by sampling the surface at each region cell's centre. As the algorithm only interpolates, and doesn't extrapolate, a margin of 0.5 (for bilinear) or 1.5 (for bicubic) cells is lost from the extent of the original raster. Any samples taken within this margin will be null.
  • r.resamp.rst Regularized Spline with Tension (RST) interpolation 2D: Behaves similarly, i.e. it computes a surface assuming that the values are samples at each raster cell's centre, and samples the surface at each region cell's centre.
  • r.resamp.bspline resamples with bicubic or bilinear spline interpolation with Tykhonov regularization.
  • r.resamp.filter resamples raster map layers using an analytic kernel. It offers box, bartlett, gauss, normal, hermite, sinc, lanczos1, lanczos2, lanczos3, hann, hamming, and blackman kernels.

Resampling of raster maps to coarser resolution

  • For r.resamp.stats resamples raster map layers to a coarser grid using aggregation. Used without -w, the value of each region cell is the chosen aggregate of the values from all of the raster cells whose centres fall within the bounds of the region cell. With -w, the samples are weighted according to the proportion of the raster cell which falls within the bounds of the region cell, so the result is normally unaffected by rounding error (a miniscule difference in the position of the boundary results in the addition or subtraction of a sample weighted by a miniscule factor; also, The min and max aggregates can't use weights, so -w has no effect for those).

Reinterpolation of "sparse" (scattered points or lines) maps

v.surf.icw interpolating around barriers

Heat maps (kernel density)

Binning

While not being a real interpolation method, raster binning generates raster maps from vector points. Vector points in XYZ format (CSV or ASCII file) can be rasterized (binning into raster cells) using univariate statistics:

Filling of holes

Sometimes no-data areas in raster maps (continuous surfaces) needs to be filled using interpolation:

Optionally extra raster sample points can be generated from an auxiliary raster maps using r.random, merged into the target raster maps with r.patch and then filled using interpolation with r.fillnulls.

Comparing original and interpolated data

  • Statistical assessment: Use r.mapcalc to calculate a differences map, then r.univar to calculates univariate statistics of the differences
  • Graphical comparison g.gui.mapswipe - Interactively compares two maps by swiping a visibility bar.

See also