| makecumsumSurface | R Documentation |
Converts normalized probability surface (e.g. one layer output of isotopeAssignmentModel function) to cumulative sum surfaces, i.e., one where the new value of a given cell is equal to the sum of all old values less than or equal to the old value of the cell.
makecumsumSurface(indivraster, rescale = FALSE, rename = FALSE)
indivraster |
Normalized probability surface SpatRaster |
rescale |
Rescale between 0 and 1? Defaults to FALSE. |
rename |
Character value to append to raster name (e.g. "_odds"). Defaults to FALSE. |
Returns SpatRaster rescaled to Cumulative Sum values.
cumsumAtSamplingLocation
# Generate example probability surfaces. The isoscape is coarsened here so the
# example runs quickly; cumsumbelow() scales with the square of the cell count.
myiso <- terra::aggregate(rast(isoscape, type = "xyz"), 5)
myiso_sd <- terra::aggregate(rast(isoscape_sd, type = "xyz"), 5)
df <- data.frame(
ID = c(-100, -80, -50),
isotopeValue = c(-100, -80, -50),
SD_indv = rep(5, 3)
)
assignmentModels <- isotopeAssignmentModel(
ID = df$ID,
isotopeValue = df$isotopeValue,
SD_indv = df$SD_indv,
precip_raster = myiso,
precip_SD_raster = myiso_sd,
nClusters = FALSE
)
# Convert to cumulative sum surface.
cumulative_sum_surface <- terra::rast(
lapply( terra::as.list( assignmentModels ), makecumsumSurface )
)
plot(cumulative_sum_surface)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.