fill_voids_g06: Voids are filling by fitting the fill source to the...

Description Usage Arguments Details Value References Examples

View source: R/fill_voids_g06.R

Description

fitFillSource returns a DEM with its voids filled with a source locally fitted with fit_trend_surface.

Usage

1
fill_voids_g06(x, np = 3, show_progress_bar = TRUE)

Arguments

x

Raster. The dem with voids should be the first layer, the filling source or sources should be the other layer of layers.

np

degree of polynomial surface

show_progress_bar

logical.

Details

If the length of the shorter side of the bounding box of the void if less than 10, the void is not filled.

To estimate the trend surface between DEM and fill source, the area of the bounding box is quadruplicate by side duplication (the void remain centered). The trend surface is used to correct the differences between DEM and fill source. If there are more than one filled source available for the void (i.e, x has more than two layers and them have data for the given void), the algorithm uses the median of the corrected difference to estimate which is the better choice to filling the void. To obtain the median, the algorithm only uses the pixels surrounding the void.

Value

RasterStack. First layer has the dem, second layer is a metadata layer that indicate which fill source was uses in each void.

References

Grohman, G., Kroenung, G., Strebeck, J., 2006. Filling SRTM voids: the delta surface fill method. Photogramm. Eng. Remote Sensing 72, 213-216.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
r <- raster(ncol = 200, nrow = 100)
extent(r) <- extent(0, 200, 0, 100)
projection(r) <- projection(r) <- CRS("+init=epsg:32718")

###reference
set.seed(11)
reference <- fake_dem(r, n_random_data = 60, z_range = c(0, 600))
plot(reference)

set.seed(18)
fillSource <- fake_dem(r, z_range = c(0, 20))
fillSource <- fillSource - mean(fillSource[])
fillSource <- fillSource + reference
fillSource <- smooth_dem(fillSource, theta = 6)
plot(fillSource)

upperHalfCells <- 1:(ncell(r)/2)
fillSource1 <- fillSource
fillSource1[upperHalfCells] <- (fillSource * 2)[upperHalfCells]
fillSource2 <- fillSource * 2
fillSource2[upperHalfCells] <- fillSource[upperHalfCells]

p <- sampleRegular(reference, 10, sp = TRUE)
voidsMask <- fake_voids(p, void_size = 20, reference)

dem <- reference
dem[voidsMask] <- NA
plot(dem)

demF1 <- fill_voids_g06(stack(dem, fillSource1, fillSource2), show_progress_bar = TRUE)
plot(subset(demF1, 1))
plot(subset(demF1, 2))

plot(subset(demF1, 1) - reference)

hs <-
  hillShade(terrain(subset(demF1, 1), "slope"),
            terrain(subset(demF1, 1), "aspect"))
plot(hs , col = grey((0:255) / 255), legend = FALSE)

GastonMauroDiaz/rdemtools documentation built on Sept. 30, 2018, 8:22 p.m.