fillNA.Rd
Fill missing values of a given variable in a VoxelSpace object with averaged neighboring values.
Neighboring values are selected among voxels within a user-defined radius in meter and whose sampling rate (number of pulses that went through the voxel) is above a user-defined threshold. Distance between voxels is the euclidian distance between voxel centers. Fill-value may be capped by user-defined minimal and maximal values.
Default radius (if not defined by user) is set to largest dimension of voxel
size max(getVoxelSize(vxsp))
. It guarantees that default neighborhood is
isotropic.
In some cases, for instance poorly sampled area, neighboring values may all be missing or discarded. A fallback value can be provided to "force fill" suche voxels. An other option is to run again the function with larger radius or lower sampling threshold.
fillNA(
vxsp,
variable.name,
variable.min = -Inf,
variable.max = Inf,
variable.fallback,
radius,
pulse.min = 10
)
a VoxelSpace
object.
a character, the name of a variable in the VoxelSpace
a numeric, minimal value for the fill values
a numeric, maximal value for the fill values
a numeric, optional fallback value in case no fill value can be estimated from neighboring voxels.
a numeric, the radius in meter that defines the neighborhood of
a voxel. The function looks for the voxels whose center is inside a sphere
of radius radius
centered at current voxel center. Default is set to
max(getVoxelSize(vxsp))
a numeric, minimal sampling intensity (i.e. number of pulses that went through a voxel) to include neighboring voxel in the estimation of the averaged fill value.
# read voxel space
vxsp <- readVoxelSpace(system.file("extdata", "tls_sample.vox", package = "AMAPVox"))
# Randomly add some NA in PAD variable
vx <- vxsp@data
ind <- sample(vx[PadBVTotal > 0, which = TRUE], 3)
# print initial values
vx[ind, .(i, j, k, PadBVTotal)]
#> i j k PadBVTotal
#> <int> <int> <int> <num>
#> 1: 2 5 8 0.016058688
#> 2: 3 1 2 0.009724009
#> 3: 2 3 4 0.021949177
vx[ind, PadBVTotal := NA]
#> i j k ground_distance nbEchos nbSampling lgTotal lMeanTotal
#> <int> <int> <int> <num> <int> <int> <num> <num>
#> 1: 0 0 0 0.25 0 3369 1100.3662 0.3266151
#> 2: 0 0 1 0.75 0 3129 904.9130 0.2892020
#> 3: 0 0 2 1.25 0 2406 751.1223 0.3121872
#> 4: 0 0 3 1.75 0 2106 659.1803 0.3130011
#> 5: 0 0 4 2.25 0 1919 602.4054 0.3139163
#> ---
#> 416: 6 5 5 2.75 0 1533 495.9831 0.3235376
#> 417: 6 5 6 3.25 0 1394 458.5256 0.3289280
#> 418: 6 5 7 3.75 0 1261 422.9537 0.3354113
#> 419: 6 5 8 4.25 0 823 283.2120 0.3441215
#> 420: 6 5 9 4.75 0 813 288.8458 0.3552839
#> sdLength angleMean bsPotential bsEntering bsIntercepted transmittance
#> <num> <num> <num> <num> <num> <num>
#> 1: 0.1866441 68.74669 0.18236696 0.18164480 0 1
#> 2: 0.1943504 61.30513 0.17215119 0.17109131 0 1
#> 3: 0.1980757 54.47612 0.13515397 0.13368462 0 1
#> 4: 0.1985490 52.09007 0.12226181 0.12128547 0 1
#> 5: 0.1975347 51.82097 0.11477382 0.11332583 0 1
#> ---
#> 416: 0.1947745 51.03537 0.09570192 0.09483800 0 1
#> 417: 0.1926026 52.84722 0.08968004 0.08821365 0 1
#> 418: 0.1887876 54.56818 0.08480823 0.08081702 0 1
#> 419: 0.1861656 71.59585 0.06110164 0.05498709 0 1
#> 420: 0.1826305 72.38877 0.06070402 0.05445548 0 1
#> PadBVTotal attenuation_FPL_biasedMLE attenuation_FPL_biasCorrection
#> <num> <num> <num>
#> 1: 0 0 0
#> 2: 0 0 0
#> 3: 0 0 0
#> 4: 0 0 0
#> 5: 0 0 0
#> ---
#> 416: 0 0 0
#> 417: 0 0 0
#> 418: 0 0 0
#> 419: 0 0 0
#> 420: 0 0 0
#> attenuation_FPL_unbiasedMLE weightedEffectiveFreepathLength
#> <num> <num>
#> 1: 0 0.05982848
#> 2: 0 0.04976479
#> 3: 0 0.04226232
#> 4: 0 0.03827859
#> 5: 0 0.03578283
#> ---
#> 416: 0 0.03092307
#> 417: 0 0.02917568
#> 418: 0 0.02708526
#> 419: 0 0.01887177
#> 420: 0 0.01926193
#> weightedFreepathLength attenuation_PPL_MLE distLaser
#> <num> <num> <num>
#> 1: 0.05956666 0 3.585220
#> 2: 0.04955374 0 3.768980
#> 3: 0.04207453 0 3.980582
#> 4: 0.03810857 0 4.410619
#> 5: 0.03562487 0 4.757694
#> ---
#> 416: 0.03078603 0 5.328756
#> 417: 0.02904613 0 5.649271
#> 418: 0.02696477 0 5.863010
#> 419: 0.01878658 0 6.421073
#> 420: 0.01917410 0 6.466489
# fill NA in PAD variable
fillNA(vxsp, "PadBVTotal", variable.max = 5)
#> i j k ground_distance nbEchos nbSampling lgTotal lMeanTotal
#> <int> <int> <int> <num> <int> <int> <num> <num>
#> 1: 0 0 0 0.25 0 3369 1100.3662 0.3266151
#> 2: 0 0 1 0.75 0 3129 904.9130 0.2892020
#> 3: 0 0 2 1.25 0 2406 751.1223 0.3121872
#> 4: 0 0 3 1.75 0 2106 659.1803 0.3130011
#> 5: 0 0 4 2.25 0 1919 602.4054 0.3139163
#> ---
#> 416: 6 5 5 2.75 0 1533 495.9831 0.3235376
#> 417: 6 5 6 3.25 0 1394 458.5256 0.3289280
#> 418: 6 5 7 3.75 0 1261 422.9537 0.3354113
#> 419: 6 5 8 4.25 0 823 283.2120 0.3441215
#> 420: 6 5 9 4.75 0 813 288.8458 0.3552839
#> sdLength angleMean bsPotential bsEntering bsIntercepted transmittance
#> <num> <num> <num> <num> <num> <num>
#> 1: 0.1866441 68.74669 0.18236696 0.18164480 0 1
#> 2: 0.1943504 61.30513 0.17215119 0.17109131 0 1
#> 3: 0.1980757 54.47612 0.13515397 0.13368462 0 1
#> 4: 0.1985490 52.09007 0.12226181 0.12128547 0 1
#> 5: 0.1975347 51.82097 0.11477382 0.11332583 0 1
#> ---
#> 416: 0.1947745 51.03537 0.09570192 0.09483800 0 1
#> 417: 0.1926026 52.84722 0.08968004 0.08821365 0 1
#> 418: 0.1887876 54.56818 0.08480823 0.08081702 0 1
#> 419: 0.1861656 71.59585 0.06110164 0.05498709 0 1
#> 420: 0.1826305 72.38877 0.06070402 0.05445548 0 1
#> PadBVTotal attenuation_FPL_biasedMLE attenuation_FPL_biasCorrection
#> <num> <num> <num>
#> 1: 0 0 0
#> 2: 0 0 0
#> 3: 0 0 0
#> 4: 0 0 0
#> 5: 0 0 0
#> ---
#> 416: 0 0 0
#> 417: 0 0 0
#> 418: 0 0 0
#> 419: 0 0 0
#> 420: 0 0 0
#> attenuation_FPL_unbiasedMLE weightedEffectiveFreepathLength
#> <num> <num>
#> 1: 0 0.05982848
#> 2: 0 0.04976479
#> 3: 0 0.04226232
#> 4: 0 0.03827859
#> 5: 0 0.03578283
#> ---
#> 416: 0 0.03092307
#> 417: 0 0.02917568
#> 418: 0 0.02708526
#> 419: 0 0.01887177
#> 420: 0 0.01926193
#> weightedFreepathLength attenuation_PPL_MLE distLaser
#> <num> <num> <num>
#> 1: 0.05956666 0 3.585220
#> 2: 0.04955374 0 3.768980
#> 3: 0.04207453 0 3.980582
#> 4: 0.03810857 0 4.410619
#> 5: 0.03562487 0 4.757694
#> ---
#> 416: 0.03078603 0 5.328756
#> 417: 0.02904613 0 5.649271
#> 418: 0.02696477 0 5.863010
#> 419: 0.01878658 0 6.421073
#> 420: 0.01917410 0 6.466489
# print filled values
vx[ind, .(i, j, k, PadBVTotal)]
#> i j k PadBVTotal
#> <int> <int> <int> <num>
#> 1: 2 5 8 0.018013984
#> 2: 3 1 2 0.009480777
#> 3: 2 3 4 0.021149232