Мне было интересно, возможно ли удалить выбросы из набора растровых данных Данные
> library (raster)
> ras <- raster("08_sa.tif")
> boxplot(ras)
> summary(ras)
08_sa.tif
Min. -6.010734e+17
1st Qu. -4.292327e+15
Median 3.456345e+15
3rd Qu. 5.913508e+15
Max. 3.954778e+17
NA's 0.000000e+00
> dput(ras)
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,
NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA
), offset = 0, gain = 1, inmemory = TRUE, fromdisk = FALSE,
isfactor = FALSE, attributes = list(), haveminmax = TRUE,
min = 213381595136, max = 395477771117133824, band = 1L,
unit = "", names = "Data"), legend = new(".RasterLegend",
type = character(0), values = logical(0), color = logical(0),
names = logical(0), colortable = logical(0)), title = character(0),
extent = new("Extent", xmin = 60.514678955, xmax = 97.416931152,
ymin = -0.701358795, ymax = 38.49804306), rotated = FALSE,
rotation = new(".Rotation", geotrans = numeric(0), transfun = function ()
NULL), ncols = 369L, nrows = 392L, crs = new("CRS", projargs = "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"),
history = list(), z = list())
> as.data.frame(ras,xy=TRUE) -> df.ras
> colnames(df.ras) <- c("x","y","value")
> df.ras$value[!df.ras$value %in% boxplot.stats(df.ras$value)$out] -> no.outliner
> boxplot(no.outliner)
> plot(no.outliner)
> summary(no.outliner)
Min. 1st Qu. Median Mean 3rd Qu. Max. NA's
2.134e+11 3.315e+15 5.084e+15 4.936e+15 6.538e+15 1.145e+16 113153
Без выброса «no.outlier» потерял географическое положение График «ras» перед удалением выбросов