Skip to contents

This tool can be used to fill in small gaps in a raster or digital elevation model (DEM). The gaps, or holes, must have recognized NoData values. If gaps do not currently have this characteristic, use the set_nodata_value tool and ensure that the data are stored using a raster format that supports NoData values. All valid, non-NoData values in the input raster will be assigned the same value in the output image.

Usage

wbw_fill_missing_data(
  x,
  filter_size = 11L,
  weight = 2,
  exclude_edge_nodata = FALSE
)

Arguments

x

Raster object of class WhiteboxRaster. See wbw_read_raster() for more details.

filter_size

integer in grid cells is used to determine how far the algorithm will search for valid, non-NoData values. Therefore, setting a larger filter size allows for the filling of larger gaps in the input raster.

weight

double, the IDW weight.

exclude_edge_nodata

boolean, default FALSE. It can be used to exclude NoData values that are connected to the edges of the raster. It is usually the case that irregularly shaped DEMs have large regions of NoData values along the containing raster edges. This flag can be used to exclude these regions from the gap-filling operation, leaving only interior gaps for filling.

Value

WhiteboxRaster object

Details

The algorithm uses an inverse-distance weighted (IDW) scheme based on the valid values on the edge of NoData gaps to estimate gap values. The user must specify the filter size (filter_size), which determines the size of gap that is filled, and the IDW weight (weight).

Examples

f <- system.file("extdata/dem.tif", package = "wbw")
wbw_read_raster(f) |>
  wbw_fill_missing_data()
#> +-----------------------------------------------+ 
#> | WhiteboxRaster                                |
#> | dem.tif                                       |
#> |...............................................| 
#> | bands       : 1                               |
#> | dimensions  : 726, 800  (nrow, ncol)          |
#> | resolution  : 5.002392, 5.000243  (x, y)      |
#> | EPSG        : 2193  (Linear_Meter)            |
#> | extent      : 1925449 1929446 5582091 5585717 |
#> | min value   : 63.698193                       |
#> | max value   : 361.020721                      |
#> +-----------------------------------------------+