Examples for 'raster::aggregate'


Aggregate raster cells or SpatialPolygons/Lines

Aliases: aggregate aggregate,Raster-method aggregate,SpatialPolygons-method aggregate,SpatialLines-method

Keywords: methods spatial

### ** Examples

r <- raster()
# a new aggregated raster, no values
ra <- aggregate(r, fact=10)
r <- setValues(r, runif(ncell(r)))

# a new aggregated raster, max of the values
ra <- aggregate(r, fact=10, fun=max)

# multiple layers
s <- stack(r, r*2)
x <- aggregate(s,2)

#SpatialPolygons
if (require(rgdal) & require(rgeos)) {
        p <- shapefile(system.file("external/lux.shp", package="raster"))
        p
        pa0 <- aggregate(p)
        pa0
        pa1 <- aggregate(p, by='NAME_1', sums=list(list(mean, 'ID_2')))
        pa1
}
Loading required package: rgdal
Warning in library(package, lib.loc = lib.loc, character.only = TRUE,
logical.return = TRUE, : there is no package called 'rgdal'
Loading required package: rgeos
rgeos version: 0.5-9, (SVN revision 684)
 GEOS runtime version: 3.10.2-CAPI-1.16.0 
 Please note that rgeos will be retired by the end of 2023,
plan transition to sf functions using GEOS at your earliest convenience.
 GEOS using OverlayNG
 Linking to sp version: 1.5-0 
 Polygon checking: TRUE 

[Package raster version 3.5-15 Index]