Description Usage Arguments Details Value See Also Examples
View source: R/utils-spatial.R
This is a convenience function returning a named list
of
functions.
1 | rangeTraits(..., use.default = TRUE)
|
... |
functions, given as myfun = FUN, to apply on a
|
use.default |
If |
The function returns a named list so any additional functions should be
given as rangeTraits(funName1 = FUN1, funName2 = FUN2) where FUN1, FUN2 are
SpatialPolygons
extractor functions.
Returns a named list containing extractor functions to apply on
SpatialPolygons
objects.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | summary(rangeTraits(use.default = FALSE))
f = system.file(package = "rangeMapper", "extdata", "wrens", "vector")
troaed = selectShpFiles(f, ogr = TRUE,
polygons.only = TRUE)[71, ] # path to Troglodytes_aedon
require(rgdal)
r = readOGR(troaed$dsn, troaed$layer)
# Beware of the value returned for Area!
sapply(rangeTraits(), function(x) x(r) )
# Define an extra function to compute correct Area
Area2 = function(x) {
x = spTransform(x,
CRS("+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs")
)
sum(sapply(slot(x, "polygons"), function(x) slot(x, "area") ))
}
sapply(rangeTraits(Area_sqm = Area2), function(x) x(r) )
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.