freq.Rd
Frequency table of the values of a RasterLayer.
# S4 method for class 'RasterLayer'
freq(x, digits=0, value=NULL, useNA='ifany', progress='', ...)
# S4 method for class 'RasterStackBrick'
freq(x, digits=0, value=NULL, useNA='ifany', merge=FALSE, progress='', ...)
RasterLayer
non-negative integer for rounding the cell values. Argument is passed to round
numeric, logical or NA. An optional single value to only count the number of cells with that value
character. What to do with NA values? Options are "no", "ifany", "always". See to table
character to specify a progress bar. Choose from 'text', 'window', or ” (the default, no progress bar)
logical. If TRUE
the list will be merged into a single data.frame
additional arguments (none implemented)
matrix (RasterLayer). List of matrices (one for each layer) or data.frame (if merge=TRUE
) (RasterStack or RasterBrick)
r <- raster(nrow=18, ncol=36)
values(r) <- runif(ncell(r))
r[1:5] <- NA
r <- r * r * r * 5
freq(r)
#> value count
#> [1,] 0 326
#> [2,] 1 102
#> [3,] 2 87
#> [4,] 3 54
#> [5,] 4 53
#> [6,] 5 21
#> [7,] NA 5
freq(r, value=2)
#> [1] 87
s <- stack(r, r*2, r*3)
freq(s, merge=TRUE)
#> value layer.1 layer.2 layer.3
#> 1 0 326 261 224
#> 2 1 102 109 102
#> 3 2 87 42 51
#> 4 3 54 43 29
#> 5 4 53 45 22
#> 6 5 21 29 34
#> 7 6 NA 25 29
#> 8 7 NA 27 24
#> 9 8 NA 29 20
#> 10 9 NA 22 12
#> 11 10 NA 11 22
#> 12 11 NA NA 16
#> 13 12 NA NA 18
#> 14 13 NA NA 19
#> 15 14 NA NA 12
#> 16 15 NA NA 9
#> 17 NA 5 5 5