Learn R Programming

adehabitatMA (version 0.3.17)

lowres: Reducing the Resolution of a Map

Description

lowres is used to reduce the resolution of maps of class SpatialPixelsDataFrame.

Usage

lowres(x, np = 2, which.fac=NULL, ...)

Value

Returns an object of class SpatialPixelsDataFrame.

Arguments

x

an object of class SpatialPixelsDataFrame

np

a number giving the number of pixels to merge together (see below)

which.fac

a vector containing the indices of the columns of x, which should be considered as a factor

...

further arguments passed to or from other methods

Author

Clement Calenge clement.calenge@ofb.gouv.fr

Details

The function merges together squares of np * np pixels. For variables of type "numeric", the function averages the value of the variable. For maps of type "factor", the function gives the most frequent level in the square of np * np pixels. When several levels are equally represented in the square of np * np pixels, the function randomly samples one of these levels.

See Also

SpatialPixelsDataFrame-class for further information on objects of class SpatialPixelsDataFrame.

Examples

Run this code
data(meuse.grid)
m <- SpatialPixelsDataFrame(points = meuse.grid[c("x", "y")],
                            data = meuse.grid)
m

m <- m[,3:6]

## The initial image
image(m,3)

## The transformed image
m2 <- lowres(m, np = 4)
image(m2, 3)

Run the code above in your browser using DataLab