Description Usage Arguments Details Value Note Author(s) References See Also Examples
Apply a chosen SQL
or R function at each grid cell, allowing for complex subsetting at both ID (e.g. species) and pixel (e..g assemblage) levels.
1 | rangeMap.save(CON, tableName, FUN, biotab, biotrait, subset, path , overwrite, ...)
|
CON |
An sqlite connection pointing to a valid |
tableName |
Name of the table (quoted) to be added to the sqlite database. The prefix ‘MAP’ will be appended to |
FUN |
the function to be applied to each pixel. If |
biotab |
character string identifying the ‘BIO’ table to use. |
biotrait |
character string identifying the ID of the ‘BIO’ table. see |
subset |
A named |
path |
Path to the raster file(quoted) to be imported to the existing project. |
overwrite |
If |
... |
When |
The subset argument accepts a named list. Names refers to ‘BIO’, ‘MAP’ and ‘metadata_rages’ table names
while the strings in the list are character strings containing the SQL WHERE
clause.
The subset can point to either one table type
(e.g. list(MAP_species_richness = "species_richness > 500")
)
or can point to several table types
(e.g. list(BIO_lifeHistory = "clutch_size > 4", MAP_meanAltitude = "meanAltitude < 1000", metadata_ranges = "Area < 1000")
)
Any valid SQL expression can be used to build up a subset. See http://www.sqlite.org/lang_expr.html
TRUE
when the MAP was created successfully.
rangeMap.fetch
returns a SpatialPixelsRangeMap-class
.
SQL
aggregate functions are more efficient then their R counterparts. For simple aggregate functions like mean, median, sd, count it is advisable to use SQL
functions rather then R functions.
Mihai Valcu valcu@orn.mpg.de
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)
RSQLite.extfuns
for a list of additional SQL aggregate functions.
metadataUpdate
.
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 35 36 37 | require(rangeMapper)
dbcon = rangeMap.start(file = "test.sqlite", overwrite = TRUE, dir = tempdir() )
# Breeding range vector files location
f = system.file(package = "rangeMapper", "extdata", "wrens", "vector_combined")
# Save the global bounding box,
global.bbox.save(con = dbcon, bbox = f,
p4s = CRS("+proj=cea +lon_0=0 +lat_ts=30 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +no_defs") )
# upload grid size
gridSize.save(dbcon, gridSize = 200000) # cell size ~ 200km
# save canvas
canvas.save(dbcon)
summary(canvas.fetch(dbcon) )
# Upload BIO tables
data(wrens)
bio.save(con = dbcon, loc = wrens, ID = "sci_name")
# Process species ranges
r = readOGR(f, "wrens", verbose = FALSE)
processRanges(spdf = r, con = dbcon, ID = "sci_name" )
#Using sqlite aggregate functions
rangeMap.save(dbcon, FUN = "median" , biotab = "wrens",
biotrait = "body_size", tableName = "body_size")
# Fetch maps
summary(rangeMap.fetch(dbcon) )
# more examples at: http://rangemapper.orn.mpg.de/
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.