10_metadataUpdate: Updates metadata table

Description Usage Arguments Value Note Author(s) References See Also Examples

Description

Updates metadata_table of a rangeMapper project after importing ranges with processRanges.

Usage

1
metadata.update(rangeMap, FUN, name, map, overwrite = FALSE, ...)

Arguments

rangeMap

A rangeMap object.

FUN

Function used to aggregate the map values corresponding to each range

name

The name of the new metadata_table field containing the variable computed by FUN

map

Single-band SpatialGridDataFrame object

overwrite

If set to TRUE the the values of the field are replaced

...

extra arguments (e.g. na.rm = TRUE) to be passed to FUN.

Value

Nothing is returned.

Note

In order to compute taxa-level metadata which are not dependent on the project's resolution use processRanges with a metadata argument. See rangeTraits for more details.
The method can be extended to work with raster or vector objects (e.g. lines, polygons, points) using overlaying functions in the package raster and rgeos respectively.

Author(s)

Mihai Valcu valcu@orn.mpg.de

References

Valcu, M., Dale, J. and Kempenaers, B. (2012) rangeMapper: A platform for the study of macroecology of life history traits. 21(9). (DOI: 10.1111/j.1466-8238.2011.00739.x)

See Also

processRanges
rangeTraits

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require(rangeMapper)

# data
spdf = readOGR(system.file(package = "rangeMapper", 
	"extdata", "wrens", "vector_combined"), "wrens", verbose = FALSE)
rloc = system.file(package = "rangeMapper", "extdata",
	"etopo1", "etopo1_Americas.tif")
r = readGDAL(rloc, output.dim = c(50, 50))
spdf = spTransform(spdf, CRS(proj4string(r)) )

# the project 
dbcon = rangeMap.start(file = "wrens.sqlite", overwrite = TRUE, 
	dir = tempdir() )
rmap = new("rangeMap", CON = dbcon)	
global.bbox.save(con = dbcon, bbox = spdf )
gridSize.save(dbcon, gridSize = 300000)  
canvas.save(dbcon) 
processRanges(spdf = spdf, con =  dbcon, ID = "sci_name" )

# metadata.update
metadata.update (rmap,
			FUN = function(x, ...) {
				res = diff(range(x, ...))
				if( !is.finite(res)) res = 0
				res 
				},
	name = 'AltitudeRange', map = r, na.rm = TRUE, overwrite = TRUE)

# plot
mr = RMQuery(dbcon, 'select * from metadata_ranges')
maxRangeSp = mr[mr$AltitudeRange== max(mr$AltitudeRange), 'bioid']
image(r)
plot(rangeFetch(rmap, maxRangeSp), add = TRUE, border = 4, lwd = 3)
title(main = maxRangeSp)

rangeMapper documentation built on May 2, 2019, 5 p.m.