Learn R Programming

inlabru (version 2.6.0)

stransform: Coordinate transformation for spatial objects

Description

This is a wrapper for the spTransform function provided by the sp package. Given a spatial object (or a list thereof) it will transform the coordinate system according to the parameter crs. In addition to the usual spatial objects this function is also capables of transforming INLA::inla.mesh objects that are equipped with a coordinate system.#'

Usage

stransform(splist, crs)

Value

List of Spatial* objects

Arguments

splist

list of Spatial* objects

crs

Coordinate reference system to change to

Examples

Run this code
# \donttest{
# Load Gorilla data
data("gorillas", package = "inlabru")

# Take the mesh and transform it to latitude/longitude
tmesh <- stransform(gorillas$mesh, crs = CRS("+proj=longlat"))

# Compare original and transformed mesh

if (require(ggplot2, quietly = TRUE)) {
  multiplot(
    ggplot() +
      gg(gorillas$mesh) +
      ggtitle("Original mesh"),
    ggplot() +
      gg(tmesh) +
      ggtitle("Transformed mesh")
  )
}
# }

Run the code above in your browser using DataLab