Learn R Programming

rangeMapper (version 2.0.3)

rmap_prepare: Define a canvas and process ranges

Description

rmap_prepare updates a 'raw' unprepared project to a ready to use project. rmap_prepare creates the project's canvas and assign each range to its corresponding canvas cells by performing a spatial intersection between the ranges and the canvas. The canvas is a regular grid of squares or hexagons.

Usage

rmap_prepare(con, grid_type, cellsize, chunksize, ...)

# S4 method for rmapConnection,character,numeric,missing rmap_prepare(con, grid_type, cellsize, chunksize, ...)

# S4 method for rmapConnection,character,numeric,numeric rmap_prepare(con, grid_type = "hex", cellsize, chunksize = 1/10, ...)

Value

TRUE when the table is written to the project file, FALSE otherwise.

Arguments

con

a rangeMapper connection made with rmap_connect().

grid_type

character "hex" (default) or "square", see sf::st_make_grid().

cellsize

target cellsize, see sf::st_make_grid().

chunksize

parallel processing chunk size expressed as proportion from the range size. Default to 1/10.

...

further arguments passed to sf::st_make_grid()

Details

Because rmap_prepare can be potentially time consuming it can be run in parallel using the support provided by the future package. future allows parallel processing on a variety of systems including high performance computing environments. For details see future::plan(). Additionally, you can keep track of of the computations using progressr::handlers().

References

Birch, C. P., Oom, S. P., & Beecham, J. A. (2007). Rectangular and hexagonal grids used for observation, experiment and simulation in ecology. Ecological modelling, 206(3-4), 347-359.

See Also

rmap_add_ranges()

Examples

Run this code

# IN-MEMORY PROJECT
require(rangeMapper)
wrens = read_wrens()
con = rmap_connect() 
rmap_add_ranges(con, wrens, 'sci_name')
rmap_prepare(con, 'hex', cellsize=500)
dbDisconnect(con)

if (FALSE) {

# PROJECT PREPARED IN PARALLEL

require(future) 
require(progressr)
plan(multisession, workers = 2)
handlers(global = TRUE)

Path = tempfile() 
con = rmap_connect(Path)
rmap_add_ranges(con, wrens, 'sci_name')

rmap_prepare(con, 'hex', cellsize=200, chunksize = 0.1)

dbDisconnect(con)
plan(sequential)
}

Run the code above in your browser using DataLab