spex: Polygon extent

Description Usage Arguments Details Value Warning See Also Examples

View source: R/spex.R

Description

Create Spatial Polygons with projection metadata from a 'Spatial Extent'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
spex(x, ...)

## Default S3 method:
spex(x, crs, byid = FALSE, .id, ...)

## S3 method for class 'Extent'
spex(x, crs, ...)

## S3 method for class 'sf'
spex(x, crs, ...)

Arguments

x

any object with a Extent

...

arguments for methods

crs

a projection string

byid

return a separate object for every input sub-object (not yet implemented)

.id

optional name for output attribute name

Details

Called with no arguments will return the extent of the current 'par("usr")' setting. This function is to replace a common pattern in the 'sp'-'raster' family which is

In short, this pattern exists because there is no projection metadata stored with either sp”s bbox or 'raster”s Extent.

Value

'SpatialPolygonsDataFrame'

Warning

Please note that an extent converted to polygons consists of only four unique coordinates, and so this is not necessarily suited for projection transformations.

See Also

This pattern is displayed in the example code for cover.

Examples

1
2
3
4
5
6
7
8
9
library(raster)
data(lux)
exlux <- spex(lux)

plot(lux)
plot(exlux, add = TRUE)

## put an extent and a CRS together
spex(extent(0, 1, 0, 1), crs = "+proj=laea +ellps=WGS84")

spex documentation built on June 8, 2018, 1:14 a.m.