Data can be filtered by null, edge values, global outliers and spatial outliers or local defective observations. Default values are optimized for precision agricultural data.
Arguments
- x
an
sfpoints object- y
characterwith the name of the variable to use for depuration/filtering process- toremove
charactervector specifying the procedure to implement for errors removal. Default 'edges', 'outlier', 'inlier'. See Details.- crs
coordinate reference system: integer with the EPSG code, or character with proj4string to convert coordinates if
xhas longitude/latitude data- buffer
numericdistance in meters to be removed. Negative values are recommended- ylimitmax
numericof length 1 indicating the maximum limit for theyvariable. IfNAInfis assumed- ylimitmin
numericof length 1 indicating the minimum limit for theyvariable. IfNA-Infis assumed- sdout
numericvalues outside the interval \(mean ± sdout × sdout\) values will be removed- ldist
numericlower distance bound to identify neighbors- udist
numericupper distance bound to identify neighbors- criteria
characterwith "LM" and/or "MP" for methods to identify spatial outliers- zero.policy
default NULL, use global option value; if FALSE stop with error for any empty neighbors sets, if TRUE permit the weights list to be formed with zero-length weights vectors
- poly_border
sfobject with one polygon or NULL. Can be the result ofconcaveman::concaveman
Value
an object of class paar with two elements:
- depurated_data
sfobject with the data after the removal process- condition
charactervector with the condition of each observation
Details
Possible values for toremove are one or more elements of:
- edges
All data points for a distance of
bufferm from data edges are deleted.- outlier
Values that are outside the mean±
sdoutare removed- inlier
Local Moran index of spatial autocorrelation is calculated for each datum as a tool to identify inliers
References
Vega, A., Córdoba, M., Castro-Franco, M. et al. Protocol for automating error removal from yield maps. Precision Agric 20, 1030–1044 (2019). https://doi.org/10.1007/s11119-018-09632-8
Examples
library(sf)
data(barley, package = 'paar')
#Convert to an sf object
barley <- st_as_sf(barley,
coords = c("X", "Y"),
crs = 32720)
depurated <-
depurate(barley,
"Yield")
#> Concave hull algorithm is computed with
#> concavity = 2 and length_threshold = 0
# Summary of depurated data
summary(depurated)
#> normal point border spatial outlier MP spatial outlier LM
#> 5673 (77%) 964 (13%) 343 (4.6%) 309 (4.2%)
#> global min outlier
#> 99 (1.3%) 6 (0.081%)
# Keep only depurate data
depurated_data <- depurated$depurated_data
# Combine the condition for all data
all_data_condition <- cbind(depurated, barley)
