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.

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

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

Value

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

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

Examples

# IN-MEMORY PROJECT require(rangeMapper) wrens = read_wrens() con = rmap_connect() rmap_add_ranges(con, wrens, 'sci_name') rmap_prepare(con, 'hex', cellsize=500)
#> --> Making hex canvas ...
#> done.
#> (i) The canvas has 576 cells.
#> --> Processing 84 ranges ...
#> --> Updating rmap_nfo & rmap_master tables ...
#> done.
#> (i) Finished in 0.091s elapsed (0.103s cpu)
dbDisconnect(con) # \dontrun{ # 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)
#> --> Making hex canvas ...
#> done.
#> (i) The canvas has 3397 cells.
#> --> Processing 84 ranges using 10 chunks ...
#> --> Updating rmap_nfo & rmap_master tables ...
#> done.
#> (i) Finished in 3.593s elapsed (0.536s cpu)
dbDisconnect(con) plan(sequential) # }