Description Usage Arguments Details Value Examples
View source: R/rasterPartFun.R
The rasterPartition
function first rasterizes the spatial polygons of the case and population data based on their respective input resolutions, and then, overlays these rasters to generate the raster of partitions of the local-EM algorithm. It also applies the kernel smoothing function with input bandwidths to the expected counts of the fine polygons to obtain the smoothed offsets (i.e., smoothed expected counts per cell area) of the partitions. If cross-validation is specified, smoothed offsets are computed for each cross-validation set.
1 2 3 4 | rasterPartition(polyCoarse, polyFine, cellsCoarse, cellsFine, bw,
focalSize = NULL, xv = NULL, ncores = 1, path = getwd(),
idFile = "lemId.grd", offsetFile = "lemOffsets.grd",
verbose = FALSE)
|
polyCoarse |
Spatial polygons of case data |
polyFine |
Spatial polygons of population data |
cellsCoarse |
Minimum resolution for rasterization of case data for numerical accuracy of smoothing matrix |
cellsFine |
Minimum resolution for rasterization of population data for numerical integration of smoothing matrix |
bw |
Vector of bandwidths |
focalSize |
Distance to truncate Gaussian kernel, default is 2.5 times largest bandwidth |
xv |
(Optional) Number of cross-validation sets, or matrix where rows are coarse polygons and columns are cross-validation sets |
ncores |
Number of cores/threads for parallel processing |
path |
Folder to store raster data |
idFile |
Filename (must have .grd extension) of the raster of partitions |
offsetFile |
Filename (must have .grd extension) of the rasters of smoothed offsets |
verbose |
Verbose output |
After using the rasterPartition
function, the partition raster is a raster stack containing the IDs for the partitions created by overlaying the rasterizations of the spatial polygons of case and population data. The offset raster is a raster stack containing the offsets of the partitions smoothed with the specified bandwidths. These values represent the denominator of the kernel smoothing matrix.
The rasterPartition
function returns a list containing the raster of the case data, raster stacks of the partitions and offsets, focal weight matrix of the Gaussian kernel, and the input coarse polygons.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | ## Not run:
# case and population data
data('kentuckyCounty')
data('kentuckyTract')
# parameters
ncores = 2
cellsCoarse = 8
cellsFine = 100
bw = c(10, 15, 17.5, 20) * 1000
path = 'example'
# rasters of case and population data
lemRaster = rasterPartitionSingle(polyCoarse = kentuckyCounty,
polyFine = kentuckyTract,
cellsCoarse = cellsCoarse,
cellsFine = cellsFine,
bw = bw,
ncores = ncores,
path = path,
idFile = 'lemId.grd',
offsetFile = 'lemOffsets.grd',
verbose = TRUE)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.