spatial.tools (version 1.6.0)

bbox_to_SpatialPolygons: Create a SpatialPolygons Bounding Box

Description

Create a SpatialPolygons Bounding Box

Usage

bbox_to_SpatialPolygons(x, proj4string = CRS(as.character(NA)))

Arguments

x

Raster*, extent, bbox or matrix. See Details.

proj4string

CRS object. Used to define the CRS if it is missing from x.

Value

A SpatialPolygons object.

Details

This function generates a SpatialPolygons object from either a Raster* object, an extent object, a bbox object, or a 2x2 Matrix that follows the form generated by the bbox() function (rows = x and y, cols = min and max). Note that with extent and matrix objects, the CRS will need to be set manually.

See Also

bbox, extent

Examples

Run this code
# NOT RUN {
library("raster")
tahoe_highrez <- brick(system.file("external/tahoe_highrez.tif", package="spatial.tools"))
bbox_to_SpatialPolygons(tahoe_highrez)
tahoe_highrez_extent <- extent(tahoe_highrez)
bbox_to_SpatialPolygons(tahoe_highrez_extent,
	CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
tahoe_highrez_bbox <- bbox(tahoe_highrez)
bbox_to_SpatialPolygons(tahoe_highrez_bbox,
	CRS("+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"))
# }

Run the code above in your browser using DataLab