rmap_save_map {rangeMapper}R Documentation

Save maps

Description

Maps are aggregate summaries computed for each canvas cell.

Usage

rmap_save_map(con, fun, src, v, subset, dst, ...)

## S4 method for signature 
## 'rmapConnection,missing,missing,missing,missing,missing'
rmap_save_map(con)

## S4 method for signature 
## 'rmapConnection,missing,missing,missing,character,character'
rmap_save_map(con, subset, dst)

## S4 method for signature 
## 'rmapConnection,character,character,character,missing,character'
rmap_save_map(con, fun, src, v, dst)

## S4 method for signature 
## 'rmapConnection,character,character,character,character,character'
rmap_save_map(con, fun, src, v, subset, dst)

## S4 method for signature 
## 'rmapConnection,‘function',character,character,missing,character’
rmap_save_map(con, fun, src, v, subset, dst, ...)

## S4 method for signature 
## 'rmapConnection,‘function',character,character,character,character’
rmap_save_map(con, fun, src, v, subset, dst, ...)

## S4 method for signature 
## 'rmapConnection,‘function',character,ANY,missing,character’
rmap_save_map(con, fun, src, v, subset, dst, ...)

## S4 method for signature 
## 'rmapConnection,‘function',character,ANY,character,character’
rmap_save_map(con, fun, src, v, subset, dst, ...)

## S4 method for signature 
## 'rmapConnection,character,Raster,missing,missing,character'
rmap_save_map(con, fun, src, v, subset, dst, ...)

Arguments

con

a rangeMapper connection made with rmap_connect().

fun

the name of the function to save, either an SQLite or an R function. see Details.

src

the name of the source table previously imported by rmap_add_bio().

v

the variable to map or a function taking several variables as arguments. and returning one or several values.

subset

the name of a subset table. see rmap_save_subset.

dst

the name of the new map table.

...

arguments passed to fun.

Details

rmap_save_map makes maps based on data within the project or based on external raster objects. Aggregate functions can be:

Value

TRUE when a table or a database view is written to the project file, FALSE otherwise.

Examples

require(rangeMapper)
require(data.table)
con = rmap_connect()
wrens = read_wrens()
rmap_add_ranges(con, x = wrens, ID = 'sci_name')
rmap_prepare(con, 'hex', cellsize=500)
rmap_save_map(con) # default is a species_richness map.

rmap_add_bio(con, wrens, 'sci_name')
rmap_save_map(con, fun='avg', src='wrens',v='body_mass', dst='avg_bodymass')

rmap_save_subset(con,dst ='ss1', species_richness = 'species_richness > 10')
rmap_save_map(con,subset = 'ss1', dst ='sr2')
rmap_save_map(con, fun='avg', src='wrens',v='body_mass', 
 subset='ss1', dst='avg_bodymass_high_SR')

rmap_save_map(con, fun= mean, na.rm = TRUE, src='wrens',
 v='body_mass', dst='mean_bodymass')

Median = function(x) median(x,na.rm = TRUE)

rmap_save_map(con, fun = Median, src='wrens',
 v='body_mass', dst='median_bodymass')

rmap_save_map(con, fun= mean, na.rm = TRUE, src='wrens',v='body_mass', 
 subset='ss1', dst='mean_bodymass_high_SR')

linmod = function(x) {
  lm(clutch_size ~ log(female_tarsus), x) %>% 
  summary %>% coefficients %>% data.table %>% .[-1] }
rmap_save_map(con, fun= linmod, src='wrens', dst='slope_clutch_size')

data(dem)
rmap_save_map(con, fun= 'mean', src= dem ,  dst='dem', progress = FALSE)

x = rmap_to_sf(con)

dbDisconnect(con)


[Package rangeMapper version 2.0.3 Index]