rangeTraits: A container of functions to apply on a 'SpatialPolygons'...

Description Usage Arguments Details Value See Also Examples

Description

This is a convenience function returning a named list of functions.

Usage

1
rangeTraits(..., use.default = TRUE)

Arguments

use.default

If TRUE, the default, the output list contains functions to extract Area, Median, Min and Max extent of the SpatialPolygons object. This option is ignored if no functions are given.

...

functions, given as myfun = FUN, to apply on a SpatialPolygons object

Details

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.

Value

Returns a named list containing extractor functions to apply on SpatialPolygons objects.

See Also

processRanges.

Examples

 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) )


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

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.