Learn R Programming

GeoModels (version 2.2.1)

sp2Geo: Extracting information from an sp or spacetime object

Description

Extracting information from an sp or spacetime object

Usage

sp2Geo(spobj,spdata = NULL)

Value

A list with spatio-temporal informations

Arguments

spobj

An object of class sp or spacetime

spdata

Character: The name of data in the sp or spacetime object

Details

The function accepts as input a sp or spacetime object and the name of the data of interest in the object and it returns a list with some useful informations for Geomodels functions.

Examples

Run this code
# Define the spatial-coordinates of the points:
set.seed(3)
N <- 30  # number of location sites
x <- runif(N, 0, 1)
set.seed(6)
y <- runif(N, 0, 1)
coords <- cbind(x,y)

# Define spatial matrix covariates and regression parameters
X <- cbind(rep(1,N),runif(N))
# Define spatial matrix dependent variable
Y <- rnorm(nrow(X))

obj1 <- sp::SpatialPoints(coords)
obj2 <- sp::SpatialPointsDataFrame(coords,data = data.frame(X,Y))

# sp2Geo info extraction
b <- sp2Geo(obj2,spdata  = "Y")
class(b)
b

Run the code above in your browser using DataLab