Learn R Programming

adehabitatMA (version 0.3.17)

subsetmap: Storing a Part of a Map

Description

subsetmap is used to store a part of any given map of class SpatialPixelsDataFrame into an other object.

Usage

subsetmap(x, xlim = NULL, ylim = NULL, ...)

Value

Returns an object of class SpatialPixelsDataFrame

Arguments

x

an object of class SpatialPixelsDataFrame

xlim

numerical vector of length 2. The x limits of the rectangle including the new map

ylim

numerical vector of length 2. The y limits of the rectangle including the new map

...

further arguments passed to or from other methods

Author

Clement Calenge clement.calenge@ofb.gouv.fr, improvements by Jon Olav Vik

Details

If xlim or ylim are not provided, the function asks the user to click on the map to delimit the lower left corner and the higher right corner of the new map (see Examples).

Examples

Run this code

data(lynxjura)
map <- lynxjura$map

## limits of the new map:
xl <- c(839938.7, 858990.8)
yl <- c(2149019, 2168761)

## computation of the new map:
su <- subsetmap(map, xlim = xl, ylim = yl)
su

## Display
opar <- par(mar = c(0,0,0,0))
layout(matrix(c(1,1,1,1,1,1,1,1,2), byrow = TRUE, ncol = 3))
image(map, axes = FALSE)
polygon(c(xl[1], xl[2], xl[2], xl[1]),
        c(yl[1], yl[1], yl[2], yl[2]))
image(su, axes = FALSE)
box()

par(opar)
par(mfrow = c(1,1))


if (FALSE) {
 ## Interactive example 
 su <- subsetmap(map)

 image(su)
}

Run the code above in your browser using DataLab