areapart {SpatEntropy} | R Documentation |
Area partition.
Description
This function partitions the observation area in a number of sub-areas, and assigns the data points/pixels to the areas. This function is useful either when a random partition wants to be created, or when the user wants to set the area's centroids and is happy with an area tessellation in Voronoi polygons according to the defined centroids.
Usage
areapart(data, G, cell.size = 1, win = NULL, plotout = T)
Arguments
data |
If data are lattice, a data matrix, which can be numeric, factor, character, ...
If the dataset is a point pattern, |
G |
An integer if sub-areas are randomly generated, determining the number |
cell.size |
A single number. If data are lattice, the length of the side of each pixel. Default to 1. Ignored if data are points. |
win |
Optional, the observation area given as a |
plotout |
Logical. Default to |
Details
The function is preliminary to the computation of Batty's or Karlstrom and Ceccato's entropy. An event of interest (in the form of a point or binary areal dataset) occurs over an observation area divided into sub-areas. If the partition is random, this function generates the sub-areas by randomly drawing the areas' centroids over the observation window. Then, data points/pixels are assigned to the area with the closest centroid. When data are pixels, each pixel is assigned to an area according to the coordinates of its own centroid. The function also works for non-binary datasets and marked ppp objects.
Value
A list with elements:
-
G.pp
a point pattern containing theG
areas' centroids -
data.assign
a four column matrix, with all pairs of data coordinates and data values matched to one of theG
areas (numbered 1 toG
). If the dataset is an unmarked ppp object, the data category column is a vector of 1s.
Moreover, a plot is produced showing the data and the area partition.
Examples
#LATTICE DATA
data=matrix(sort(sample(c("a","b","c"), 100, replace=TRUE)), nrow=10)
partition=areapart(data, G=5)
partition=areapart(data, G=5, cell.size=2)
#providing a pre-fixed area partition
data=matrix(sort(sample(c("a","b","c"), 100, replace=TRUE)), nrow=10)
win=square(nrow(data))
GG=cbind(runif(5, win$xrange[1], win$xrange[2]),
runif(5, win$yrange[1], win$yrange[2]))
partition=areapart(data, G=GG)
#POINT DATA
data=ppp(x=runif(100), y=runif(100), window=square(1))
partition=areapart(data, 10)
#with marks
data=ppp(x=runif(100), y=runif(100), window=square(1),
marks=(sample(c("a","b","c"), 100, replace=TRUE)))
GG=cbind(runif(10, data$window$xrange[1], data$window$xrange[2]),
runif(10, data$window$yrange[1], data$window$yrange[2]))
partition=areapart(data, G=GG)