View source: R/dsmartr_helpers.R
strict_cfp | R Documentation |
Determines which covariate cells intersect with a given map polygon.
strict_cfp(src_map = NULL, covariates = NULL)
src_map |
An sfc_POLYGON/MULTIPOLYGON or SpatialPolygonsDataFrame object representing the soil map to be disaggregated. Attributes are not required. |
covariates |
RasterStack or RasterBrick; environmental covariate datasets. |
Given a polygon layer and spatially intersecting raster object,
determines which raster cells intersect which polygons. This function is
primarily intended for use in prep_polygons
but can be used
as a standalone.
a list of atomic vectors containing raster cell numbers.
## Not run:
data('heronvale_soilmap')
data('heronvale_covariates')
# just get the list object
intersecting_cells <- strict_cfp(src_map = heronvale_soilmap,
covariates = heronvale_covariates)
# to check that this output is complete and non overlapping
r_blank <- raster(heronvale_covariates)
r_blank[] <- 1:ncell(r_blank)
dup_chk <- table(unlist(intersecting_cells)) # all shld be freq = 1
values(r_blank)[!(values(r_blank) %in% as.data.frame(dup_chk)$Var1)] <- NA
plot(r_blank) # only cells underlying the polygons are kept
# or place it in a new list-column for later use
heronvale_soilmap$int_cells <- strict_cfp(src_map = heronvale_soilmap,
covariates = heronvale_covariates)
# as above, tidyverse style
library(dplyr)
heronvale_soilmap <- heronvale_soilmap %>%
mutate(int_cells = strict_cfp(., heronvale_covariates))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.