bbox_to_SpatialPolygons: Create a SpatialPolygons Bounding Box

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/bbox_to_SpatialPolygons.R

Description

Create a SpatialPolygons Bounding Box

Usage

1
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.

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.

Value

A SpatialPolygons object.

Author(s)

Jonathan A. Greenberg

See Also

bbox, extent

Examples

1
2
3
4
5
6
7
8
9
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"))

Example output

Loading required package: parallel
Loading required package: iterators
Loading required package: foreach
Loading required package: rgdal
Loading required package: sp
rgdal: version: 1.2-10, (SVN revision 673)
 Geospatial Data Abstraction Library extensions to R successfully loaded
 Loaded GDAL runtime: GDAL 1.10.1, released 2013/08/26
 Path to GDAL shared files: /usr/share/gdal/1.10
 Loaded PROJ.4 runtime: Rel. 4.8.0, 6 March 2012, [PJ_VERSION: 480]
 Path to PROJ.4 shared files: (autodetected)
WARNING: no proj_defs.dat in PROJ.4 shared files
 Linking to sp version: 1.2-3 
Loading required package: raster
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : SpatialPolygons 
features    : 1 
extent      : -119.9328, -119.9306, 39.28922, 39.29141  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : SpatialPolygons 
features    : 1 
extent      : -119.9328, -119.9306, 39.28922, 39.29141  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
class       : SpatialPolygons 
features    : 1 
extent      : -119.9328, -119.9306, 39.28922, 39.29141  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0 

spatial.tools documentation built on May 2, 2019, 6:52 p.m.