PaleoRegion: R6 class representing a paleontological region.

PaleoRegionR Documentation

R6 class representing a paleontological region.

Description

R6 class representing a study region of temporally changing spatial grid cells, defined via a RasterLayer object (see raster) and a temporal mask indicating which cells are included at each time step.

Super classes

poems::GenericClass -> poems::Region -> PaleoRegion

Public fields

attached

A list of dynamically attached attributes (name-value pairs).

Active bindings

coordinates

Data frame (or matrix) of X-Y population (WGS84) coordinates in longitude (degrees West) and latitude (degrees North) (get and set), or distance-based coordinates dynamically returned by region raster (get only).

region_raster

A RasterLayer object (see raster) defining the region with finite values (NAs elsewhere).

use_raster

Boolean to indicate that a raster is to be used to define the region (default TRUE).

strict_consistency

Boolean to indicate that, as well as resolution, extent and CRS, consistency checks also ensure that a raster's finite/occupiable cells are the same or a subset of those defined by the region (default TRUE).

temporal_mask

Matrix of booleans indicating which region cells are included at each time step.

region_cells

Dynamically calculated number of region coordinates or raster cells with finite/non-NA values.

region_indices

Dynamically calculated region indices for raster cells with finite/non-NA values (all if not a raster).

Methods

Public methods

Inherited methods

Method new()

Initialization method sets temporally changing raster layers for paleontological region.

Usage
PaleoRegion$new(template_raster = NULL, remove_zeros = FALSE, ...)
Arguments
template_raster

A RasterLayer, RasterBrick, or RasterStack object (see raster) defining the paleontological region with example finite values (NAs elsewhere)

remove_zeros

Boolean to indicate that cells that are zero across all layers (times) are to be removed, i.e. set to NA (default is FALSE).

...

Additional parameters passed individually.


Method raster_from_values()

Converts an array (or matrix) of values into a raster (or stack) consistent with the region raster (matching extent, resolution, and finite/NA cells), and with the temporal mask (if any) applied.

Usage
PaleoRegion$raster_from_values(values)
Arguments
values

An array (or matrix) of values to be placed in the raster (or stack) having dimensions consistent with the region cell number.

Returns

A RasterLayer (or RasterStack/Brick) object consistent with the region raster with temporal mask (if any) applied.


Method temporal_mask_raster()

Returns the temporal mask as a raster stack/brick object consistent with the region raster.

Usage
PaleoRegion$temporal_mask_raster()
Returns

A RasterStack/Brick) object with temporal mask values of 1 (true) and NA elsewhere.


Method clone()

The objects of this class are cloneable with this method.

Usage
PaleoRegion$clone(deep = FALSE)
Arguments
deep

Whether to make a deep clone.

Examples

library(poems)
library(raster)
# Ring Island example region
coordinates <- data.frame(x = rep(seq(-178.02, -178.06, -0.01), 5),
                          y = rep(seq(19.02, 19.06, 0.01), each = 5))
template_raster <- Region$new(coordinates = coordinates)$region_raster # full extent
sealevel_raster <- template_raster
template_raster[][c(7:9, 12:14, 17:19)] <- NA # make Ring Island
sealevel_raster[][c(7:9, 12:14, 17:18)] <- NA
raster_stack <- raster::stack(x = append(replicate(9, template_raster), sealevel_raster))
region <- PaleoRegion$new(template_raster = raster_stack)
raster::plot(region$temporal_mask_raster()[[1]], main = "Ring Island (first timestep)",
             xlab = "Longitude (degrees)", ylab = "Latitude (degrees)",
             colNA = "blue", legend = FALSE)
raster::plot(region$temporal_mask_raster()[[10]], main = "Ring Island (last timestep)",
             xlab = "Longitude (degrees)", ylab = "Latitude (degrees)",
             colNA = "blue", legend = FALSE)


paleopop documentation built on Oct. 11, 2023, 5:14 p.m.