Learn R Programming

arkhe (version 0.2.2)

geography: Spatial Information

Description

Deal with spatial information.

Usage

get_coordinates(object)

set_coordinates(object) <- value

# S4 method for Matrix get_coordinates(object)

# S4 method for Matrix set_coordinates(object) <- value

Arguments

object

An object from which to get or set element(s).

value

A possible value for the element(s) of object (see below).

Details

An attempt is made to interpret the argument value in a way suitable for geographic coordinates.

If value is a:

list

containing components "x", "y" and "z", these are used to define coordinates (longitude, latitude and elevation, respectively). If "z" is missing, the vertical coordinates will be ignored (and NA will be generated).

matrix or data.frame with two or more columns

the first is assumed to contain the x values, the second the y and the third the z values. Note that if value has columns named "x", "y" and "z", these columns will be used. If value has only two columns or has columns named "x" and "y" but not "z", the vertical coordinates will be ignored (and NA will be generated).

Examples

Run this code
# NOT RUN {
## Create a count data matrix
A <- CountMatrix(data = sample(0:10, 100, TRUE), nrow = 10, ncol = 10,
                 dimnames = list(LETTERS[1:10], NULL))

## Set geographic coordinates as a matrix
B <- matrix(data = sample(0:10, 30, TRUE), nrow = 10, ncol = 3)
set_coordinates(A) <- B
get_coordinates(A)

## Set geographic coordinates as a data.frame
B <- data.frame(sample(0:10, 5, TRUE), sample(0:10, 5, TRUE), sample(0:10, 5, TRUE),
                row.names = LETTERS[seq(1, 10, 2)])
set_coordinates(A) <- B
get_coordinates(A)

## Set geographic coordinates as a list
B <- list(X = sample(0:10, 10, TRUE), Y = sample(0:10, 10, TRUE))
set_coordinates(A) <- B
get_coordinates(A)

## Unset geographic coordinates
set_coordinates(A) <- NULL
get_coordinates(A)
# }

Run the code above in your browser using DataLab