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
spex(x, ...)

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

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

Arguments

x

any object with a Extent

...

arguments for methods

byid

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

.id

optional name for output attribute name

crs

a projection string

Details

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 May 30, 2017, 7:18 a.m.

Search within the spex package
Search all R packages, documentation and source code