| sp2Geo | R Documentation |
Extracting information from an sp or spacetime object
sp2Geo(spobj,spdata = NULL)
spobj |
An object of class sp or spacetime |
spdata |
Character: The name of data in the sp or spacetime object |
The function accepts an sp or spacetime object and returns information used by GeoModels functions. Spatial objects should have a coordinate reference system (CRS) defined; if the CRS is missing, sp2Geo issues a warning because projected/geographic status cannot be determined reliably. For STFDF and STIDF objects, the current conversion represents the temporal positions by the sequential indices 1, 2, ..., T; the original spacing of an irregular time index is therefore not preserved. To retain irregular temporal distances, use the explicit-coordinate interfaces of the relevant GeoModels functions and supply the numeric coordt values directly rather than passing spobj.
A list with spatio-temporal information
Moreno Bevilacqua, moreno.bevilacqua89@gmail.com,https://sites.google.com/view/moreno-bevilacqua/home, Víctor Morales Oñate, victor.morales@uv.cl, https://sites.google.com/site/moralesonatevictor/, Christian Caamaño-Carrillo, chcaaman@ubiobio.cl,https://www.researchgate.net/profile/Christian-Caamano
if (requireNamespace("sp", quietly = TRUE)) {
# 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))
crs <- sp::CRS("EPSG:4326")
obj1 <- sp::SpatialPoints(coords, proj4string = crs)
obj2 <- sp::SpatialPointsDataFrame(
coords, data = data.frame(X, Y), proj4string = crs
)
# sp2Geo info extraction
b <- sp2Geo(obj2,spdata = "Y")
class(b)
b
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.