Learn R Programming

pedometrics (version 0.12.1)

bbox2sp: Create a Spatial* object from a bounding box

Description

Take the bounding box of a Spatial* object and create a SpatialPoints* or SpatialPolygons* object from it.

Usage

bbox2sp(obj, sp = "SpatialPolygons", keep.crs = TRUE)

Arguments

obj

Object of class Spatial*.

sp

Class of the resulting object with options "SpatialPolygons" (default), "SpatialPoints", "SpatialPointsDataFrame", and "SpatialPolygonsDataFrame".

keep.crs

Logical for assigning the same coordinate reference system to the resulting Spatial* object. Defaults to keep.crs = TRUE.

Value

An object of class SpatialPoints* or SpatialPolygons*.

Dependencies

The sp package, provider of classes and methods for spatial data in R, is required for bbox2sp() to work. The development version of the sp package is available on https://github.com/edzer/sp/ while its old versions are available on the CRAN archive at https://cran.r-project.org/src/contrib/Archive/sp/.

References

Edzer Pebesma, Jon Skoien with contributions from Olivier Baume, A. Chorti, D.T. Hristopulos, S.J. Melles and G. Spiliopoulos (2013). intamapInteractive: procedures for automated interpolation - methods only to be used interactively, not included in intamap package. R package version 1.1-10. https://CRAN.R-project.org/package=intamapInteractive.

Examples

Run this code
# NOT RUN {
if (require(sp)) {
  data(meuse, package = "sp")
  sp::coordinates(meuse) <- ~ x + y
  bb <- bbox2sp(obj = meuse, keep.crs = FALSE)
}
# }

Run the code above in your browser using DataLab