I was wondering if it's possible to remove outliers from Raster datasetData
> 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(x[1:10, 1:10])
6158433346650112, NA, NA, NA, NA, 2607742007115776, 2877426224857088,
3185328672210944, 3353694611439616, 3688539120205824, 3618639601205248,
3899686960234496, 4037082158727168
> 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
Without outlier 'no.outlier' has lost it geographical location
Plot of 'ras' before removing outliers