Learn R Programming

pop (version 0.1)

landscape: landscape objects

Description

landscape objects represent sets of patches forming a metapopulation, storing information (such as area, population and environmental features) that may impact on the dynamic transitions occurring in each component patch. dynamic objects all have a landscape object (by default a single-patch landscape) as a an attribute which can be accessed and set via the function landscape. as.landscape is used to create landscape objects, and the functions population, area, distance and features access and set each of the elements of a landscape.

Usage

landscape(dynamic)
landscape(dynamic) <- value
as.landscape(patches)
is.landscape(x)
"print"(x, ...)
area(landscape)
area(landscape) <- value
population(landscape)
population(landscape) <- value
features(landscape)
features(landscape) <- value
distance(landscape)
distance(landscape) <- value
"[["(x, i)

Arguments

dynamic
an object of class dynamic
value
an object of class landscape (for landscape(dynamic) <- value) or the value to assign to the distance, area, population, or features elements of a landscape object
patches
an object to turn into a landscape object. Currently this can either be a dynamic, a list or NULL (see details), though more approaches will be added in the future
x
an object to print or test as a landscape object
landscape
an object of class landscape
i
index specifying the patches to include in the subset landscape object
...
further arguments passed to or from other methods.

Value

an object of class landscape, essentially a dataframe containing the coordinates, area, population and features (as columns) for each patch (rows)

Details

The accessor function landscape either returns or sets the landscape structure of the dynamic, encoded as a landscape object

patches can be a list containing the following elements: population, a dataframe giving the number of individuals of each stage (columns) within each patch (rows); area, a one-column dataframe giving the areas of the patches in square kilometres; coordinates, a dataframe giving the coordinates of the habitat patches; and features, a dataframe containing miscellaneous features (columns) of the patches (rows), such as measures of patch quality or environmental variables. Alternatively, patches = NULL, will set up a 'default' one-patch landscape with area = data.frame(area =1), coordinates = data.frame(x = 0, y = 0) and blank population and features elements. The other option is to pass a dynamic object as patches, in which case the set up will be the same as for patches = NULL except that population will be a one-row dataframe of 0s, with columns corresponding to the states in the dynamic. This is what's used when analysing a dynamic object without user-specified metapopulation structure.

the accessor functions distance, area, population and features either return or set corresponding sub-dataframes of the landscape object

Examples

Run this code
# create a default landscape
landscape <- as.landscape(NULL)

# create a marginally more interesting one-patch landscape
landscape <- as.landscape(list(coordinates = data.frame(x = c(10, 11),
                                                        y = c(11, 12)),
                               area = data.frame(area = 10),
                               population = data.frame(adult = 10,
                                                       larva = 3,
                                                       egg = 20),
                               features = data.frame(temperature = 10)))
# print method
print(landscape)

# get and set the area
area(landscape)
area(landscape) <- area(landscape) * 2
area(landscape)

# get and set the population
population(landscape)
population(landscape) <- population(landscape) * 2
population(landscape)

# get and set the features
features(landscape)
features(landscape) <- cbind(features(landscape), rainfall = 100)
features(landscape)

# get and set the distance matrix
distance(landscape)
distance(landscape) <- sqrt(distance(landscape))
distance(landscape)

# landscapes can be subsetted to get sub-landscapes of patches with double
# braces
landscape
landscape[[1]]
landscape[[1:2]]

Run the code above in your browser using DataLab