Learn R Programming

tabula (version 1.3.0)

geography: Spatial Information

Description

Experimental tools to deal with spatial information.

Usage

get_features(object)

get_coordinates(object)

set_coordinates(object) <- value

get_epsg(object)

set_epsg(object) <- value

# S4 method for AbundanceMatrix get_coordinates(object)

# S4 method for AbundanceMatrix get_epsg(object)

# S4 method for AbundanceMatrix get_features(object)

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

# S4 method for AbundanceMatrix set_epsg(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).

Set coordinates

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).

get_features converts an AbundanceMatrix object to a collection of features (i.e. adata.frame with dates and coordinates columns) that can be used for spatial manipulation with sf.

Examples

Run this code
# NOT RUN {
## Create a count data matrix
A1 <- CountMatrix(data = sample(0:10, 100, TRUE),
                  nrow = 10, ncol = 10, byrow = TRUE)

## Set geographic coordinates
set_epsg(A1) <- 4326
set_coordinates(A1) <- list(X = sample(0:10, 10, TRUE),
                            Y = sample(0:10, 10, TRUE))
get_coordinates(A1)

# }
# NOT RUN {
## Convert to a sf object (the sf package must be installed on your machine)
# feat <- get_features(A1)
# sf::st_as_sf(feat, crs = 4326, coords = c("X", "Y"), dim = "XY",
#              remove = FALSE, na.fail = TRUE)
# }

Run the code above in your browser using DataLab