spex: spex

Description Usage Arguments Details Value Spatial Extent Warning See Also Examples

View source: R/spex.R

Description

spex

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'

Spatial Extent

spex function to produce a fully fledged Spatial object extent

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
10
11
12
13
14
15
16
17
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")
## Not run: 
 ## library(rgdal)
 ## p4 <- "+proj=laea +ellps=WGS84"
 ## plot(spTransform(lux, p4))
 ## warning, this is just 4 coordinates
 ## plot(spTransform(exlux, p4), add = TRUE)

## End(Not run)

spex documentation built on Aug. 3, 2017, 5:04 p.m.

Related to spex in spex...