R6
class representing a generic (abstract)
spatially-explicit model. It extends GenericModel
with the addition of
a study region specification.
Super classes
poems::GenericClass
-> poems::GenericModel
-> SpatialModel
Active bindings
model_attributes
A vector of model attribute names.
region
A
Region
(or inherited class) object specifying the study region.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).
attribute_aliases
A list of alternative alias names for model attributes (form:
alias = "attribute"
) to be used with the set and get attributes methods.error_messages
A vector of error messages encountered when setting model attributes.
warning_messages
A vector of warning messages encountered when setting model attributes.
Methods
Method new()
Initialization method sets given attributes individually and/or from a list.
Usage
SpatialModel$new(region = NULL, ...)
Arguments
region
A
Region
(or inherited class) object specifying the study region....
Parameters passed individually.
Method new_clone()
Creates a new (re-initialized) object of the current (inherited) object class with optionally passed parameters.
Examples
# U Island example region
coordinates <- data.frame(
x = rep(seq(177.01, 177.05, 0.01), 5),
y = rep(seq(-18.01, -18.05, -0.01), each = 5)
)
template_raster <- Region$new(coordinates = coordinates)$region_raster # full extent
template_raster[][-c(7, 9, 12, 14, 17:19)] <- NA # make U Island
region <- Region$new(template_raster = template_raster)
# Example spatial model
model1 <- SpatialModel$new(region = region, a_layers = 3)
model1$coordinates
#> x y
#> 1 177.02 -18.02
#> 2 177.04 -18.02
#> 3 177.02 -18.03
#> 4 177.04 -18.03
#> 5 177.02 -18.04
#> 6 177.03 -18.04
#> 7 177.04 -18.04
model1$set_attributes(a_values = array(8:28, c(7, 3)))
model1$region$raster_from_values(model1$get_attribute("a_values"))
#> class : RasterBrick
#> dimensions : 5, 5, 25, 3 (nrow, ncol, ncell, nlayers)
#> resolution : 0.01, 0.01 (x, y)
#> extent : 177.005, 177.055, -18.055, -18.005 (xmin, xmax, ymin, ymax)
#> crs : +proj=longlat +ellps=WGS84 +towgs84=0,0,0,0,0,0,0 +no_defs
#> source : memory
#> names : layer.1, layer.2, layer.3
#> min values : 8, 15, 22
#> max values : 14, 21, 28
#>